Skip to content

Logging

Pawel Plesniak edited this page Dec 5, 2024 · 3 revisions

Python's logging is poorly documented, especially when it defines inheritance of the loggers drunc has a pseudo-root logger defined, called drunc. Each subsequent child logger is referenced by the class name as drunc.X. The loggers have broadly been grouped as drunc.process_manager.X. drunc.controller.X, etc. Each logger has either a RichHandler (process_manager, as this is what we see when running drunc in the terminal), or a StreamHandler (for everything else). There is also optional file handling, but this is only used for the process_manager as the spawned processes have their logs defined when the ouptu is redirected from stdout and stderr to the log file.

Loggers for classes are named as

self.log = get_logger(<path_from_drunc_root>.<file_name_no_ext>.<class_name>)

aside from children nodes which have .<child_name> appended. Loggers for functions and static methods are named as

self.log = get_logger(<path_from_drunc_root>.<file_name_no_ext>.<function_name>)