Permalink
Browse files

Refactor Logger creation

Make FileLogger::create, SyslogLogger::create, DatabaseLogger::create.  Also
make the *Logger::setupZMQSocket return false on failure, and move the
nzmqt exception handling much tighter around the code that would be raising
the exceptions. Added exception handling in the client logger too.
  • Loading branch information...
1 parent 8aab7dd commit 8f3225ce252fa3c0337dadd696269e67b6598a27 @Beirdo Beirdo committed Jun 19, 2012
Showing with 257 additions and 176 deletions.
  1. +27 −19 mythtv/libs/libmythbase/logging.cpp
  2. +220 −153 mythtv/libs/libmythbase/loggingserver.cpp
  3. +10 −4 mythtv/libs/libmythbase/loggingserver.h
@@ -303,29 +303,37 @@ void LoggerThread::run(void)
LOG(VB_GENERAL, LOG_INFO, "Added logging to the console");
- if (m_locallogs)
+ try
{
- logServerWait();
- m_zmqContext = logServerThread->getZMQContext();
- }
- else
- {
- m_zmqContext = nzmqt::createDefaultContext(NULL);
- m_zmqContext->start();
- }
+ if (m_locallogs)
+ {
+ logServerWait();
+ m_zmqContext = logServerThread->getZMQContext();
+ }
+ else
+ {
+ m_zmqContext = nzmqt::createDefaultContext(NULL);
+ m_zmqContext->start();
+ }
- qRegisterMetaType<QList<QByteArray> >("QList<QByteArray>");
+ qRegisterMetaType<QList<QByteArray> >("QList<QByteArray>");
- m_zmqSocket = m_zmqContext->createSocket(nzmqt::ZMQSocket::TYP_DEALER,
- this);
- connect(m_zmqSocket, SIGNAL(messageReceived(const QList<QByteArray>&)),
- SLOT(messageReceived(const QList<QByteArray>&)),
- Qt::QueuedConnection);
+ m_zmqSocket = m_zmqContext->createSocket(nzmqt::ZMQSocket::TYP_DEALER,
+ this);
+ connect(m_zmqSocket, SIGNAL(messageReceived(const QList<QByteArray>&)),
+ SLOT(messageReceived(const QList<QByteArray>&)),
+ Qt::QueuedConnection);
- if (m_locallogs)
- m_zmqSocket->connectTo("inproc://mylogs");
- else
- m_zmqSocket->connectTo("tcp://127.0.0.1:35327");
+ if (m_locallogs)
+ m_zmqSocket->connectTo("inproc://mylogs");
+ else
+ m_zmqSocket->connectTo("tcp://127.0.0.1:35327");
+ }
+ catch (nzmqt::ZMQException &e)
+ {
+ cerr << "Exception during logging socket setup: " << e.what() << endl;
+ qApp->quit();
+ }
if (!m_locallogs)
{
Oops, something went wrong.

0 comments on commit 8f3225c

Please sign in to comment.