Add a NO_MSG_HANDLER cmake option

This allows QDebug to output to stdout or OutputDebugString
to ease development.
This commit is contained in:
Jocelyn Turcotte 2015-02-19 16:49:39 +01:00
parent 5e1aa7d383
commit 2ddaf5a06a
2 changed files with 11 additions and 0 deletions

View File

@ -102,6 +102,11 @@ if(TOKEN_AUTH_ONLY)
add_definitions(-DTOKEN_AUTH_ONLY=1)
endif()
option(NO_MSG_HANDLER "Don't redirect QDebug outputs to the log window/file" OFF)
if(NO_MSG_HANDLER)
add_definitions(-DNO_MSG_HANDLER=1)
endif()
# this option creates only libocsync and libowncloudsync
option(BUILD_LIBRARIES_ONLY "BUILD_LIBRARIES_ONLY" OFF)

View File

@ -53,14 +53,20 @@ Logger *Logger::instance()
Logger::Logger( QObject* parent) : QObject(parent),
_showTime(true), _doLogging(false), _doFileFlush(false), _logExpire(0)
{
#ifndef NO_MSG_HANDLER
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
qSetMessagePattern("%{time MM-dd hh:mm:ss:zzz} %{threadid} %{function}: %{message}");
#endif
qInstallMessageHandler(mirallLogCatcher);
#else
Q_UNUSED(mirallLogCatcher)
#endif
}
Logger::~Logger() {
#ifndef NO_MSG_HANDLER
qInstallMessageHandler(0);
#endif
}