myxlib/examples/qt/03_message-logger/message_logger.cpp

30 lines
839 B
C++

#include <myx/qt/message_logger_default.hpp>
#include <myx/qt/message_logger_handler.hpp>
#include <myx/qt/message_logger_syslog.hpp>
#include <QCoreApplication>
#include <QDebug>
namespace MQ = myx::qt;
int main( int argc, char* argv[] )
{
QCoreApplication app( argc, argv );
auto mld = QSharedPointer< MQ::MessageLoggerDefault >( new MQ::MessageLoggerDefault );
MQ::messageLoggersList.append( mld );
MQ::messageLoggersList.append( mld );
auto mls = QSharedPointer< MQ::MessageLoggerSyslog >( new MQ::MessageLoggerSyslog );
MQ::messageLoggersList.append( mls );
qInstallMessageHandler( MQ::message_logger_handler );
qDebug() << "Hello from process:" << QCoreApplication::applicationPid();
qWarning() << "Warning";
qInstallMessageHandler( 0 );
qDebug() << "Reset user handlers";
qWarning() << "Goodbye";
return( 0 );
}