This is used so that we can output to the log file in addition to the CLI. */
| 171 | |
| 172 | /** This is used so that we can output to the log file in addition to the CLI. */ |
| 173 | void appDebugOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg) |
| 174 | { |
| 175 | static std::mutex loggerMutex; |
| 176 | const std::lock_guard<std::mutex> lock(loggerMutex); // synchronized, QFile logFile is not thread-safe |
| 177 | |
| 178 | QString out = qFormatLogMessage(type, context, msg); |
| 179 | out += QChar::LineFeed; |
| 180 | |
| 181 | APPLICATION->logFile->write(out.toUtf8()); |
| 182 | APPLICATION->logFile->flush(); |
| 183 | QTextStream(stderr) << out.toLocal8Bit(); |
| 184 | fflush(stderr); |
| 185 | } |
| 186 | |
| 187 | } // namespace |
| 188 |