From 48932ba57b1cd28fa8495d843bbcb93d42829829 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Wed, 2 Oct 2024 15:14:27 +0200 Subject: [PATCH 1/2] enable dev logs only when NEXTCLOUD_DEV is defined to value 1 will switch back production logs to the intended behavior Signed-off-by: Matthieu Gallien --- src/gui/application.cpp | 2 +- src/libsync/logger.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 7aee62a202040..171acc75cfa8a 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -700,7 +700,7 @@ void Application::setupLogging() logger->setLogDir(_logDir.isEmpty() ? ConfigFile().logDir() : _logDir); } logger->setLogExpire(_logExpire > 0 ? _logExpire : ConfigFile().logExpire()); -#if defined NEXTCLOUD_DEV +#if defined NEXTCLOUD_DEV && NEXTCLOUD_DEV logger->setLogFlush(true); logger->setLogDebug(true); #else diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp index 060705ba6c8ef..66c853559287b 100644 --- a/src/libsync/logger.cpp +++ b/src/libsync/logger.cpp @@ -120,7 +120,7 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString { static long long int linesCounter = 0; const auto &msg = qFormatLogMessage(type, ctx, message); -#if defined Q_OS_WIN && (defined NEXTCLOUD_DEV || defined QT_DEBUG) +#if defined Q_OS_WIN && ((defined NEXTCLOUD_DEV && NEXTCLOUD_DEV) || defined QT_DEBUG) // write logs to Output window of Visual Studio { QString prefix; From 06f7cf4896be5ab62c4d12f9f0f9b76b91405f16 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Wed, 2 Oct 2024 15:21:09 +0200 Subject: [PATCH 2/2] improve debugger logs on Windows to have same content than normal log makes debugger logs more usefull Signed-off-by: Matthieu Gallien --- src/libsync/logger.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp index 66c853559287b..5e84be48ac0d7 100644 --- a/src/libsync/logger.cpp +++ b/src/libsync/logger.cpp @@ -123,24 +123,7 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString #if defined Q_OS_WIN && ((defined NEXTCLOUD_DEV && NEXTCLOUD_DEV) || 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"); + const auto msgW = QStringLiteral("%1\n").arg(msg).toStdWString(); OutputDebugString(msgW.c_str()); } #endif