dlr-gtlab / gt-logging

Basic C++14 logging library based on QsLog
0 stars 0 forks source link

Consider using noquote by default #25

Closed rainman110 closed 10 months ago

rainman110 commented 2 years ago

In GitLab by @mariusalexander on Feb 10, 2022, 11:36

What is the purpose of the change?

The logging system formats variables depending on its type. However when printing QStrings/QByteArrays and QChar additional qoutes are displayed, which may hinder readability of info and logging statements.

Consider the following code snippet:

gtDebug() << QObject::tr("This is a QString") << QString("and") << "this is a plain const char*";

The ouput will look like this:

[DEBUG] "This is a QString" "and" this is a plain const char*

The Logging system however implements a method called noquote() which will log a better formatted string (without quotes):

gtDebug().noquote() << QObject::tr("This is a QString") << QString("and") << "this is a plain const char*";

[DEBUG] This is a QString and this is a plain const char*

My proposal is to set this property globally. If a user really wants to use qoutes when logging the following code can be used regardless:

gtDebug().qoute() << QObject::tr("This is will be qouted");

[DEBUG] "This will be qouted"

(as a side note: nospace() works similar and will not print addition spaces for each input however this may not be desireable globally)

Which tasks have to be performed?

Instead of writing:

gtDebug() << QObject::tr("current obj:") << QStringLiteral("\"") + obj + QStringLiteral("\"");

to print

[DEBUG] current obj: "MyObject"

one may use the helper function to print the same output:

gtDebug() << QObject::tr("current obj:") << GtLogging::qoute(obj);

Are there any acceptance criteria to check?

rainman110 commented 2 years ago

In GitLab by @mariusalexander on Aug 23, 2022, 07:27

created branch 25-consider-using-noqoute-by-default to address this issue

rainman110 commented 1 year ago

In GitLab by @mariusalexander on Sep 26, 2022, 08:35

mentioned in commit cb1217ccf108535db71f8fc0ba31771fce0bac3b