PDA

View Full Version : Using QLoggingCategory, rules precedence seem backwards



don@thegagnes.com
5th December 2014, 01:41
I want to instrument my codebase with QLoggingCategory. The issue for me is the precedence order of the rules mechanisms given the fact that all logging is on by default. Given the fact that all logging is on by default it would make sense to set a sensible level of logging. The two mechanism to do that would be:

1) Calling setFilterRules in the code.
2) Setup a qtlogging.ini file pre-populated with those sensible settings. But that means every developer working in the code needs to take the manual setup of placing the file in the right place. That issue points me to #1

Now if I am debugging something and find that I want to turn on additional logging I would like to do that without having to modify code. The qtlogging.ini seems ideal for this since it is outside the codebase. But with the qtlogging.ini as the lowest order in the rule precedence below setFilterRules it doesn't work.

That would seem to be a common pattern to follow. Is there a different way to do the same thing, while avoiding #2?

anda_skoa
5th December 2014, 08:13
What about building qtlogging.ini into the program using Qt's resource mechanism and extracting it on startup if not present yet.

That would take care of "But that means every developer working in the code needs to take the manual setup of placing the file in the right place"

Cheers,
_

don@thegagnes.com
5th December 2014, 17:37
Hmm, yeah. Good idea. I'll try that. Thanks.

anda_skoa
5th December 2014, 19:17
You can also have a custom config file(s) somewhere inside the project and point the environment variable QT_LOGGING_CONF

Cheers,
_