[Interest] Why does the QtLogging message not include type (e.g. WARNING)?

Thomas Larsen Wessel mrvelle at gmail.com
Sun Dec 10 14:03:53 CET 2023


The documentation (https://doc.qt.io/qt-6/qtlogging.html) states:

    *The default pattern is %{if-category}%{category}: %{endif}%{message}*

1) In my limited experience most or all logging architectures print the
type (aka. severity or criticality, e.g. warning, debug, info, etc.) by
default.

2) And in my personal opinion it should be default to print this, since the
severity is often just as important as the message itself, when the goal is
to leave the user / log reader informed.

Is there a good reason why the severity is left out of the default format?

*My current situation and motivation for writing:*

I have a number of Python scripts that rely on PyQGIS, which relies on Qt.
They are part of a small software package that is distributed to a number
of machines. Each of these scripts occasionally produce log messages via
QtLogging, and they are all printed without any context (unless I set them
up differently). Its not my code that calls QtWarning, etc., they are
called from either QGIS or Qt.

Here is an example.

    *QStandardPaths: wrong permissions on runtime directory
/run/user/1000/, 0755 instead of 0700*

When someone sees this warning, they don't know if this is an error or
warning. They don't know if its severe enough that they should do something
or just ignore this. IMHO there is no doubt it should be prefixed with
"Warning", "WARN" or similar.

So now I set a custom format in each of my scripts. That works of course.
But IMHO it would make a whole lot of sense if the default format was
changed to include the severity :)

Sincerely
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20231210/6437ae00/attachment.htm>


More information about the Interest mailing list