Flush preinit log messages from mem handler into file
ClosedPublic

Authored by mkrizek on May 20 2015, 2:52 PM.

Details

Test Plan

Enable file logging and see if messages prior to file logger being initialized are flushed into taskotron.log.

Diff Detail

Repository
rLTRN libtaskotron
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mkrizek retitled this revision from to Flush preinit log messages from mem handler into file.May 20 2015, 2:52 PM
mkrizek updated this object.
mkrizek edited the test plan for this revision. (Show Details)
mkrizek added reviewers: tflink, kparal, jskladan.
tflink accepted this revision.May 22 2015, 8:07 PM
This revision is now accepted and ready to land.May 22 2015, 8:07 PM
kparal requested changes to this revision.Jun 2 2015, 3:56 PM

Hey Martin, this is awesome! I had no idea this would be so easy and that MemoryHandler is already implemented in logging. Thanks a lot for finding this out!

I've found an issue with your current patch, so I tried to fix it and add some unit tests, I hope you don't mind :-) The patch is here:
https://phab.qadevel.cloud.fedoraproject.org/differential/diff/1015/

It seems to work well, I manually tested it by editing taskotron.yaml and setting log_file_enabled and log_level_file.

In the future, I think we could even get rid of the whole method init_prior_config, and use mem_handler for forwarding to stream_handler as well, once everything is initialized. But that's not important for the moment, so if you no objections to my patch and it works for you, I think this is good to go.

libtaskotron/logger.py
131

We don't want to limit memory records to just anything above the stream level. The stream level and the file level might be different. Let's not set it at all and leave it with NOTSET, so that it contains everything.

243

I have tested this and it unfortunately forward all records to the target and the target does not filter them according to their level. If you edit taskotron.yaml and set log_level_file: INFO, you'll see that the file still contains initial DEBUG messages. So we need to do record forwarding manually.

This revision now requires changes to proceed.Jun 2 2015, 3:56 PM
This revision was automatically updated to reflect the committed changes.