Skip to content

Commit 166b9f2

Browse files
authored
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 <[email protected]> Signed-off-by: Ryan Echols <[email protected]>
1 parent 5e03f5f commit 166b9f2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

utils/general.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ def set_logging(name=None, verbose=VERBOSE):
126126
log.addHandler(handler)
127127

128128

129-
set_logging() # run before defining LOGGER
130-
LOGGER = logging.getLogger("yolov5") # define globally (used in train.py, val.py, detect.py, etc.)
129+
logger_name = "yolov5"
130+
set_logging(logger_name) # run before defining LOGGER
131+
LOGGER = logging.getLogger(logger_name) # define globally (used in train.py, val.py, detect.py, etc.)
131132
if platform.system() == 'Windows':
132133
for fn in LOGGER.info, LOGGER.warning:
133134
setattr(LOGGER, fn.__name__, lambda x: fn(emojis(x))) # emoji safe logging

0 commit comments

Comments
 (0)