diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2021-06-09 10:48:55 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-06-15 14:49:54 +0300 |
commit | 953262f312b1412a9531d18851f9396defd18649 (patch) | |
tree | af6e78c785d226996700418772fcee1b862d08ce /src | |
parent | d5bf6f5c10ce9ce75ade59b5948c15f7829198a8 (diff) |
Reuse message pattern from gui
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/cmd.cpp | 11 | ||||
-rw-r--r-- | src/libsync/logger.cpp | 7 | ||||
-rw-r--r-- | src/libsync/logger.h | 2 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index 4a9999210..06f8c6b2e 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -192,12 +192,6 @@ void sync(const SyncCTX &ctx, int restartCount) } - -static void nullMessageHandler(QtMsgType, const QMessageLogContext &, const QString &) -{ -} - - class EchoDisabler { public: @@ -412,9 +406,9 @@ int main(int argc, char **argv) SyncCTX ctx { parseOptions(app.arguments()) }; if (ctx.options.silent) { - qInstallMessageHandler(nullMessageHandler); + qInstallMessageHandler([](QtMsgType, const QMessageLogContext &, const QString &) {}); } else { - qSetMessagePattern("%{time MM-dd hh:mm:ss:zzz} [ %{type} %{category} ]%{if-debug}\t[ %{function} ]%{endif}:\t%{message}"); + qSetMessagePattern(Logger::loggerPattern()); } ctx.account = Account::create(); @@ -435,7 +429,6 @@ int main(int argc, char **argv) auto tmp = QUrl::fromUserInput(ctx.options.target_url); // Find the folder and the original owncloud url QStringList splitted = tmp.path().split("/" + ctx.account->davPath()); - qDebug() << tmp.path() << ctx.account->davPath() << splitted; tmp.setPath(splitted.value(0)); tmp.setScheme(tmp.scheme().replace("owncloud", "http")); diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp index eb41dfffe..212db9357 100644 --- a/src/libsync/logger.cpp +++ b/src/libsync/logger.cpp @@ -61,7 +61,7 @@ Logger *Logger::instance() Logger::Logger(QObject *parent) : QObject(parent) { - qSetMessagePattern(QStringLiteral("%{time MM-dd hh:mm:ss:zzz} [ %{type} %{category} ]%{if-debug}\t[ %{function} ]%{endif}:\t%{message}")); + qSetMessagePattern(loggerPattern()); _crashLog.resize(CrashLogSize); #ifndef NO_MSG_HANDLER qInstallMessageHandler([](QtMsgType type, const QMessageLogContext &ctx, const QString &message) { @@ -77,6 +77,11 @@ Logger::~Logger() #endif } +QString Logger::loggerPattern() +{ + return QStringLiteral("%{time MM-dd hh:mm:ss:zzz} [ %{type} %{category} ]%{if-debug}\t[ %{function} ]%{endif}:\t%{message}"); +} + bool Logger::isLoggingToFile() const { QMutexLocker lock(&_mutex); diff --git a/src/libsync/logger.h b/src/libsync/logger.h index 29b4fbc4d..95a0e18b0 100644 --- a/src/libsync/logger.h +++ b/src/libsync/logger.h @@ -36,6 +36,8 @@ class OWNCLOUDSYNC_EXPORT Logger : public QObject { Q_OBJECT public: + static QString loggerPattern(); + bool isLoggingToFile() const; void attacheToConsole(); |