Commit c221c012 authored by Andrey Legayev's avatar Andrey Legayev Committed by Sandro Knauß
Browse files

[Kleopatra] Add support of timestamp to logging

Summary:
Sometimes Kleopatra starts very slow on windows and get stuck sometimes.
Current version doesn't write timestamps to log file and it's hard to understand what exactly operation is slowing it down.
I've implented writing timestamp before message.
New feature can be enabled via setting environment variable KLEOPATRA_LOGOPTIONS=timestamp

Test Plan:
1. Enable logs by setting environment variable KLEOPATRA_LOGDIR=/your/log/path
2. Enable debug logs output by setting `QT_LOGGING_RULES="org.kde.pim.kleopatra.debug=true"`
2. Set environment variable `QT_MESSAGE_PATTERN="%{time yyyyMMdd h:mm:ss.zzz} %{message}"`
3. Check logs - timestamp should appear before log messages

Reviewers: aheinecke, dfaure

Reviewed By: dfaure

Subscribers: knauss, kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D28495
parent 8cc12d03
......@@ -69,9 +69,8 @@ Log::Private::~Private()
void Log::messageHandler(QtMsgType type, const QMessageLogContext &ctx, const QString& msg)
{
Q_UNUSED(type)
Q_UNUSED(ctx)
const QByteArray local8str = msg.toLocal8Bit();
const QString formattedMessage = qFormatLogMessage(type, ctx, msg);
const QByteArray local8str = formattedMessage.toLocal8Bit();
FILE *const file = Log::instance()->logFile();
if (!file) {
fprintf(stderr, "Log::messageHandler[!file]: %s", local8str.constData());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment