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 <ryan@shadylakemedia.com> Signed-off-by: Ryan Echols <ryan@shadylakemedia.com>
This commit is contained in:
1 parent
5e03f5fc8c
commit
166b9f2fa7
1 file changed
+3
-2
+3
-2
@@ -126,8 +126,9 @@ def set_logging(name=None, verbose=VERBOSE):
|
|||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
|
|
||||||
|
|
||||||
set_logging() # run before defining LOGGER
|
logger_name = "yolov5"
|
||||||
LOGGER = logging.getLogger("yolov5") # define globally (used in train.py, val.py, detect.py, etc.)
|
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':
|
if platform.system() == 'Windows':
|
||||||
for fn in LOGGER.info, LOGGER.warning:
|
for fn in LOGGER.info, LOGGER.warning:
|
||||||
setattr(LOGGER, fn.__name__, lambda x: fn(emojis(x))) # emoji safe logging
|
setattr(LOGGER, fn.__name__, lambda x: fn(emojis(x))) # emoji safe logging
|
||||||
|
|||||||
Reference in new issue
Block a user