Changeset View
Changeset View
Standalone View
Standalone View
dialer/src/main.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
47 | #include <KAboutData> | 47 | #include <KAboutData> | ||
48 | #include <KDBusService> | 48 | #include <KDBusService> | ||
49 | 49 | | |||
50 | #include <stdio.h> | 50 | #include <stdio.h> | ||
51 | #include <stdlib.h> | 51 | #include <stdlib.h> | ||
52 | 52 | | |||
53 | void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) | 53 | void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) | ||
54 | { | 54 | { | ||
55 | // TODO: print it on stdout too? | | |||
56 | QFile file(QDir::homePath() + "/dialer.log"); | 55 | QFile file(QDir::homePath() + "/dialer.log"); | ||
57 | 56 | | |||
58 | bool opened = file.open(QIODevice::WriteOnly | QIODevice::Append); | 57 | bool opened = file.open(QIODevice::WriteOnly | QIODevice::Append); | ||
59 | Q_ASSERT(opened); | 58 | Q_ASSERT(opened); | ||
60 | 59 | | |||
61 | QTextStream out(&file); | 60 | QString strout; | ||
61 | QTextStream out(&strout); | ||||
62 | out << QTime::currentTime().toString("hh:mm:ss.zzz "); | 62 | out << QTime::currentTime().toString("hh:mm:ss.zzz "); | ||
63 | out << context.function << ":" << context.line << " "; | 63 | out << context.function << ":" << context.line << " "; | ||
64 | 64 | | |||
65 | switch (type) { | 65 | switch (type) { | ||
66 | case QtDebugMsg: out << "DBG"; break; | 66 | case QtDebugMsg: out << "DBG"; break; | ||
67 | case QtInfoMsg: out << "NFO"; break; | ||||
67 | case QtWarningMsg: out << "WRN"; break; | 68 | case QtWarningMsg: out << "WRN"; break; | ||
68 | case QtCriticalMsg: out << "CRT"; break; | 69 | case QtCriticalMsg: out << "CRT"; break; | ||
69 | case QtFatalMsg: out << "FTL"; break; | 70 | case QtFatalMsg: out << "FTL"; break; | ||
70 | } | 71 | } | ||
71 | 72 | | |||
72 | out << " " << msg << '\n'; | 73 | out << " " << msg << '\n'; | ||
74 | | ||||
75 | // Write to log file | ||||
76 | QTextStream fileout(&file); | ||||
77 | fileout << strout; | ||||
73 | out.flush(); | 78 | out.flush(); | ||
79 | | ||||
80 | // Write to stdout | ||||
81 | QTextStream console(stdout); | ||||
82 | console << strout; | ||||
83 | console.flush(); | ||||
74 | } | 84 | } | ||
75 | 85 | | |||
76 | int main(int argc, char **argv) | 86 | int main(int argc, char **argv) | ||
77 | { | 87 | { | ||
78 | qInstallMessageHandler(myMessageOutput); | 88 | qInstallMessageHandler(myMessageOutput); | ||
79 | QCommandLineParser parser; | 89 | QCommandLineParser parser; | ||
80 | QApplication app(argc, argv); | 90 | QApplication app(argc, argv); | ||
81 | 91 | | |||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |