|
1 | 1 | #include "systemtray.h" |
2 | 2 | #include <DAboutDialog> |
3 | 3 | #include <DApplication> |
| 4 | +#include <DLog> |
4 | 5 |
|
5 | 6 | DWIDGET_USE_NAMESPACE |
6 | | - |
| 7 | +void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { |
| 8 | + QByteArray localMsg = msg.toLocal8Bit(); |
| 9 | + switch (type) { |
| 10 | + case QtDebugMsg: |
| 11 | + fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); |
| 12 | + break; |
| 13 | + case QtInfoMsg: |
| 14 | + fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); |
| 15 | + break; |
| 16 | + case QtWarningMsg: |
| 17 | + fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); |
| 18 | + break; |
| 19 | + case QtCriticalMsg: |
| 20 | + fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); |
| 21 | + break; |
| 22 | + case QtFatalMsg: |
| 23 | + fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); |
| 24 | + break; |
| 25 | + } |
| 26 | +} |
7 | 27 | int main(int argc, char *argv[]) { |
8 | 28 | DApplication::loadDXcbPlugin(); |
9 | 29 | DApplication app(argc, argv); |
10 | 30 |
|
| 31 | + qInstallMessageHandler(myMessageOutput); |
| 32 | + std::freopen((QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/stickyNotes.log").toStdString().c_str(), "a", stderr); |
| 33 | + std::cerr << std::endl << std::endl; |
| 34 | + |
11 | 35 | app.setAttribute(Qt::AA_UseHighDpiPixmaps); |
12 | 36 | if (!app.setSingleInstance("DStickyNotes-develop")) |
13 | 37 | return 0; |
|
0 commit comments