From 9c10f493ed91573046b2105e7c38550132bc4b09 Mon Sep 17 00:00:00 2001 From: MikhailBurdukov <102754618+MikhailBurdukov@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:00:07 +0300 Subject: [PATCH] Fix extra logs. (#74) * Fix * Update logging.py --------- Co-authored-by: Aleksei Filatov <68555560+aalexfvk@users.noreply.github.com> --- ch_backup/logging.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ch_backup/logging.py b/ch_backup/logging.py index 6049cd83..58c8f701 100644 --- a/ch_backup/logging.py +++ b/ch_backup/logging.py @@ -78,17 +78,25 @@ def configure(config_loguru: dict) -> None: "sink": value["sink"], "format": config_loguru["formatters"][value["format"]], "enqueue": True, - "filter": value["filter"] if "filter" in value else make_filter(name), } if "level" in value: handler["level"] = value["level"] + + if "filter" in value: + handler["filter"] = value["filter"] + # https://loguru.readthedocs.io/en/stable/api/logger.html#message + # One can also pass a dict mapping module names to minimum required level. In such case, each log record will search for it’s closest parent in the dict + # and use the associated level as the filter. + # In order to set a default level, the "" module name should be used as it is the parent of all modules (it does not suppress global level threshold, though). + handler["filter"][""] = False + else: + handler["filter"] = make_filter(name) loguru_handlers.append(handler) logger.configure(handlers=loguru_handlers, activation=[("", True)]) # Configure logging. logging.basicConfig(handlers=[InterceptHandler()], level=0) - logging.debug("Checkroot") def critical(msg, *args, **kwargs):