Enable file logging and see if messages prior to file logger being initialized are flushed into taskotron.log.
Details
- Reviewers
kparal tflink jskladan - Maniphest Tasks
- T273: capture pre-logger initialization messages
- Commits
- rLTRN612ad442aa09: Flush preinit log messages from mem handler into file
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.
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. |
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.