mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Stop QtWebApp from eating out debug messages
QtWebapp installs a custom logger/message handler which reroutes all debug messages to it's custom logger class. As the default logging level for QtWebApp's logger is set to "critical" this means that all debug messages are sent to nirvana. Solution: Replace QtWebApp's messageHandler with our own (using QsLog).
This commit is contained in:
parent
3530528282
commit
0e9a3a6407
@ -80,8 +80,47 @@ void logSystemAndConfig()
|
||||
QLOG_INFO() << "--------------------------------------------";
|
||||
}
|
||||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
switch (type)
|
||||
{
|
||||
case QtInfoMsg:
|
||||
{
|
||||
QLOG_INFO() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
case QtDebugMsg:
|
||||
{
|
||||
QLOG_DEBUG() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
|
||||
case QtWarningMsg:
|
||||
{
|
||||
QLOG_WARN() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
|
||||
case QtCriticalMsg:
|
||||
{
|
||||
QLOG_ERROR() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
|
||||
case QtFatalMsg:
|
||||
{
|
||||
QLOG_FATAL() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
qInstallMessageHandler(messageHandler);
|
||||
QApplication app( argc, argv );
|
||||
|
||||
#ifdef FORCE_ANGLE
|
||||
|
@ -90,7 +90,7 @@ SOURCES += \
|
||||
$$PWD/controllers/v2/taginfocontroller_v2.cpp
|
||||
|
||||
|
||||
include(lib/logging/logging.pri)
|
||||
#include(lib/logging/logging.pri)
|
||||
include(lib/httpserver/httpserver.pri)
|
||||
include(lib/templateengine/templateengine.pri)
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "static.h"
|
||||
#include "startup.h"
|
||||
#include "dualfilelogger.h"
|
||||
//#include "dualfilelogger.h"
|
||||
#include "httplistener.h"
|
||||
#include "requestmapper.h"
|
||||
#include "staticfilecontroller.h"
|
||||
@ -27,9 +27,9 @@
|
||||
void Startup::start() {
|
||||
// Initialize the core application
|
||||
QCoreApplication* app = QCoreApplication::instance();
|
||||
|
||||
QString configFileName=YACReader::getSettingsPath()+"/"+QCoreApplication::applicationName()+".ini";
|
||||
|
||||
/*
|
||||
// Configure logging into files
|
||||
QSettings* mainLogSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
mainLogSettings->beginGroup("mainLogFile");
|
||||
@ -49,7 +49,7 @@ void Startup::start() {
|
||||
mainLogSettings->setValue("minLevel",QtCriticalMsg);
|
||||
|
||||
Logger* logger=new FileLogger(mainLogSettings,10000,app);
|
||||
logger->installMsgHandler();
|
||||
logger->installMsgHandler();*/
|
||||
|
||||
// Configure template loader and cache
|
||||
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
@ -150,5 +150,3 @@ QString Startup::getPort()
|
||||
{
|
||||
return QString("%1").arg(listener->serverPort());
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,8 +44,48 @@ void logSystemAndConfig()
|
||||
QLOG_INFO() << "--------------------------------------------";
|
||||
}
|
||||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
switch (type)
|
||||
{
|
||||
case QtInfoMsg:
|
||||
{
|
||||
QLOG_INFO() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
case QtDebugMsg:
|
||||
{
|
||||
QLOG_DEBUG() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
|
||||
case QtWarningMsg:
|
||||
{
|
||||
QLOG_WARN() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
|
||||
case QtCriticalMsg:
|
||||
{
|
||||
QLOG_ERROR() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
|
||||
case QtFatalMsg:
|
||||
{
|
||||
QLOG_FATAL() << localMsg.constData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
qInstallMessageHandler(messageHandler);
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
app.setApplicationName("YACReaderLibrary");
|
||||
|
Loading…
Reference in New Issue
Block a user