mylogging.misc package¶
Contains various functions around logging. Allow you to filter out warnings from other libraries or redirect logs to list so it can be logged later (beneficial for example if using multiprocessing).
- mylogging.misc.log_and_warn_from_lists(logs_list: None | list = None, warnings_list: None | list = None) None [source]¶
When logs and warnings was redirected to python lists. This can log it from the lists to file or console. Can be useful for example if using multiprocessing.
- Parameters
logs_list (None | list, optional) – [description]. Defaults to None.
warnings_list (None | list, optional) – [description]. Defaults to None.
- Raises
RuntimeError – [description]
- mylogging.misc.redirect_logs_and_warnings(used_logs: list[logging.LogRecord], used_warnings: list, keep_logs_and_warnings: bool = True) RedirectedLogsAndWarnings [source]¶
For example if using many processes with multiprocessing, it may be beneficial to log from one place. It’s possible to log to variables (logs as well as warnings), pass it to the main process and then log it with workings filter etc.
To log stored logs and warnings, use
- Parameters
used_logs (list) – List where logs will be stored
used_warnings (list) – List where warnings will be stored
keep_logs_and_warnings (bool, optional) – If False, warnings and logs will be silenced. Default to True.
- Returns
Object, where you can reset redirect. Logs and warnings you already have from inserted parameters.
- Return type