mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
refs #446, changed log handler as discussed in slack
This commit is contained in:
committed by
Mathew Sutcliffe
parent
9b77e1fc5c
commit
9d0408138a
@@ -21,7 +21,7 @@
|
|||||||
#include "statusmessagelist.h"
|
#include "statusmessagelist.h"
|
||||||
#include "pixmap.h"
|
#include "pixmap.h"
|
||||||
#include "iconlist.h"
|
#include "iconlist.h"
|
||||||
#include "identifier.h"
|
#include "identifierlist.h"
|
||||||
#include "eventallclasses.h"
|
#include "eventallclasses.h"
|
||||||
#include <QtNetwork/QHostInfo>
|
#include <QtNetwork/QHostInfo>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
void BlackMisc::Math::registerMetadata()
|
void BlackMisc::Math::registerMetadata()
|
||||||
{
|
{
|
||||||
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -107,6 +108,7 @@ void BlackMisc::registerMetadata()
|
|||||||
CLogCategoryList::registerMetadata();
|
CLogCategoryList::registerMetadata();
|
||||||
CPixmap::registerMetadata();
|
CPixmap::registerMetadata();
|
||||||
CIdentifier::registerMetadata();
|
CIdentifier::registerMetadata();
|
||||||
|
CIdentifierList::registerMetadata();
|
||||||
|
|
||||||
// sub namespaces
|
// sub namespaces
|
||||||
PhysicalQuantities::registerMetadata();
|
PhysicalQuantities::registerMetadata();
|
||||||
|
|||||||
@@ -29,8 +29,10 @@ namespace BlackMisc
|
|||||||
QMetaObject::invokeMethod(CLogHandler::instance(), "logLocalMessage", Q_ARG(BlackMisc::CStatusMessage, statusMessage));
|
QMetaObject::invokeMethod(CLogHandler::instance(), "logLocalMessage", Q_ARG(BlackMisc::CStatusMessage, statusMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogHandler::install()
|
void CLogHandler::install(bool skipIfAlreadyInstalled)
|
||||||
{
|
{
|
||||||
|
if (skipIfAlreadyInstalled && m_oldHandler) { return; }
|
||||||
|
Q_ASSERT_X(!m_oldHandler, Q_FUNC_INFO, "Re-installing the log handler should be avoided");
|
||||||
m_oldHandler = qInstallMessageHandler(messageHandler);
|
m_oldHandler = qInstallMessageHandler(messageHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +109,13 @@ namespace BlackMisc
|
|||||||
emit remoteMessageLogged(statusMessage);
|
emit remoteMessageLogged(statusMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlackMisc::CLogHandler::enableConsoleOutput(bool enable)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(m_oldHandler, Q_FUNC_INFO, "Install the log handler before using it");
|
||||||
|
Q_ASSERT_X(thread() == QThread::currentThread(), Q_FUNC_INFO, "Wrong thread");
|
||||||
|
m_enableFallThrough = enable;
|
||||||
|
}
|
||||||
|
|
||||||
void CLogHandler::logMessage(const CStatusMessage &statusMessage)
|
void CLogHandler::logMessage(const CStatusMessage &statusMessage)
|
||||||
{
|
{
|
||||||
collectGarbage();
|
collectGarbage();
|
||||||
@@ -115,6 +124,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
if (isFallThroughEnabled(handlers))
|
if (isFallThroughEnabled(handlers))
|
||||||
{
|
{
|
||||||
|
Q_ASSERT_X(m_oldHandler, Q_FUNC_INFO, "Handler must be installed");
|
||||||
QtMsgType type;
|
QtMsgType type;
|
||||||
QString category;
|
QString category;
|
||||||
QString message;
|
QString message;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace BlackMisc
|
|||||||
static CLogHandler *instance();
|
static CLogHandler *instance();
|
||||||
|
|
||||||
//! Tell the CLogHandler to install itself with qInstallMessageHandler.
|
//! Tell the CLogHandler to install itself with qInstallMessageHandler.
|
||||||
void install();
|
void install(bool skipIfAlreadyInstalled = false);
|
||||||
|
|
||||||
//! Return a pattern handler for subscribing to all messages which match the given pattern.
|
//! Return a pattern handler for subscribing to all messages which match the given pattern.
|
||||||
//! \warning This must only be called from the main thread.
|
//! \warning This must only be called from the main thread.
|
||||||
@@ -74,11 +74,7 @@ namespace BlackMisc
|
|||||||
void logRemoteMessage(const BlackMisc::CStatusMessage &message);
|
void logRemoteMessage(const BlackMisc::CStatusMessage &message);
|
||||||
|
|
||||||
//! Enable or disable the default Qt handler.
|
//! Enable or disable the default Qt handler.
|
||||||
void enableConsoleOutput(bool enable)
|
void enableConsoleOutput(bool enable);
|
||||||
{
|
|
||||||
Q_ASSERT(thread() == QThread::currentThread());
|
|
||||||
m_enableFallThrough = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void logMessage(const BlackMisc::CStatusMessage &message);
|
void logMessage(const BlackMisc::CStatusMessage &message);
|
||||||
|
|||||||
Reference in New Issue
Block a user