mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
[dialer] Install custom qDebug messages handler
Now it logs into ~/dialer.log, this way it can be retrieved even if autostarted by Mission Control.
This commit is contained in:
parent
75124ecc74
commit
173d138134
1 changed files with 27 additions and 0 deletions
|
|
@ -47,8 +47,35 @@
|
|||
#include <KAboutData>
|
||||
#include <KDBusService>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue