diff --git a/dialer/src/main.cpp b/dialer/src/main.cpp index 106a61df..2ba77bb4 100644 --- a/dialer/src/main.cpp +++ b/dialer/src/main.cpp @@ -47,8 +47,35 @@ #include #include +#include +#include + +void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + // TODO: print it on stdout too? + QFile file("/home/phablet/dialer.log"); + + bool opened = file.open(QIODevice::WriteOnly | QIODevice::Append); + Q_ASSERT(opened); + + QTextStream out(&file); + out << QTime::currentTime().toString("hh:mm:ss.zzz "); + out << context.function << ":" << context.line << " "; + + switch (type) { + case QtDebugMsg: out << "DBG"; break; + case QtWarningMsg: out << "WRN"; break; + case QtCriticalMsg: out << "CRT"; break; + case QtFatalMsg: out << "FTL"; break; + } + + out << " " << msg << '\n'; + out.flush(); +} + int main(int argc, char **argv) { + qInstallMessageHandler(myMessageOutput); QCommandLineParser parser; QApplication app(argc, argv);