From 4f383fd87fba984a9a29cc11de14af385beeb04d Mon Sep 17 00:00:00 2001 From: David Ramirez Date: Wed, 28 Aug 2024 14:47:22 +0000 Subject: [PATCH] Added check if LOG exists --- kytos/core/controller.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kytos/core/controller.py b/kytos/core/controller.py index c12edaac..8b0f3935 100644 --- a/kytos/core/controller.py +++ b/kytos/core/controller.py @@ -205,12 +205,15 @@ def _patch_core_loggers(): reloadable_mods = [module for mod_name, module in sys.modules.items() if mod_name[:str_len] == match_str] for module in reloadable_mods: - old_logger = module.LOG - module.LOG = logging.getLogger(module.__name__) - for handler in old_logger.handlers: - module.LOG.addHandler(handler) - for log_filter in old_logger.filters: - module.LOG.addFilter(log_filter) + new_logger = logging.getLogger(module.__name__) + if hasattr(module, "LOG"): + old_logger = module.LOG + for handler in old_logger.handlers: + new_logger.addHandler(handler) + for log_filter in old_logger.filters: + new_logger.addFilter(log_filter) + module.LOG = new_logger + @staticmethod