From: Dmytro Korchynskyi Date: Sat, 18 Dec 2021 14:29:35 +0000 (+0200) Subject: write logs to Output window of Visual Studio X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~17^2~202^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c8725145711a89a8d63285511ba3c8e2f4ce412f;p=nextcloud-desktop.git write logs to Output window of Visual Studio Signed-off-by: Dmytro Korchynskyi --- diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp index 2a90c976b..294ad2bb6 100644 --- a/src/libsync/logger.cpp +++ b/src/libsync/logger.cpp @@ -89,6 +89,30 @@ bool Logger::isLoggingToFile() const void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString &message) { const QString msg = qFormatLogMessage(type, ctx, message); +#if defined(Q_OS_WIN) && defined(QT_DEBUG) + // write logs to Output window of Visual Studio + { + QString prefix; + switch (type) { + case QtDebugMsg: + break; + case QtInfoMsg: + break; + case QtWarningMsg: + prefix = QStringLiteral("[WARNING] "); + break; + case QtCriticalMsg: + prefix = QStringLiteral("[CRITICAL ERROR] "); + break; + case QtFatalMsg: + prefix = QStringLiteral("[FATAL ERROR] "); + break; + } + auto msgW = QString(prefix + message).toStdWString(); + msgW.append(L"\n"); + OutputDebugString(msgW.c_str()); + } +#endif { QMutexLocker lock(&_mutex); _crashLogIndex = (_crashLogIndex + 1) % CrashLogSize;