Skip to content

Commit

Permalink
Added check if LOG exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Ktmi committed Aug 28, 2024
1 parent e6c5089 commit 4f383fd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions kytos/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f383fd

Please sign in to comment.