From 166b9f2fa79a67788a2a372dc52c9e8e0f7a7cc1 Mon Sep 17 00:00:00 2001 From: Ryan Echols Date: Wed, 16 Nov 2022 08:09:30 -0700 Subject: [PATCH] fix: prevent logging config clobbering (#10133) Previous behavior: loading this repository with `torch.hub.load` clobbers the existing logging configuration by modifying the root logger's configuration. New behavior: loading this repository with `torch.hub.load` only clobbers the logging configuration for logger `yolov5` and its descendants. Signed-off-by: Ryan Echols Signed-off-by: Ryan Echols --- utils/general.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/general.py b/utils/general.py index 0c3b44d..76dd2a4 100644 --- a/utils/general.py +++ b/utils/general.py @@ -126,8 +126,9 @@ def set_logging(name=None, verbose=VERBOSE): log.addHandler(handler) -set_logging() # run before defining LOGGER -LOGGER = logging.getLogger("yolov5") # define globally (used in train.py, val.py, detect.py, etc.) +logger_name = "yolov5" +set_logging(logger_name) # run before defining LOGGER +LOGGER = logging.getLogger(logger_name) # define globally (used in train.py, val.py, detect.py, etc.) if platform.system() == 'Windows': for fn in LOGGER.info, LOGGER.warning: setattr(LOGGER, fn.__name__, lambda x: fn(emojis(x))) # emoji safe logging