fix: try 2 - prevent logging config clobbering #10192
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for issue #10132
torch.hub.load
clobbers the existing logging configuration by modifying the root logger's configuration.torch.hub.load
only clobbers the logging configuration for loggeryolov5
and its descendants. This is done in a way compatible with Google Colab.The new
set_logging
function uses"disable_existing_loggers": False
so that any existing logging configurations are left unchanged. It also uses"propagate": False
on the logger in question so that any log records sent to this logger are not also sent through any handlers from pre-existing logging configurations (which would duplicate messages).🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Improved logging configurability in
yolov5
utils.📊 Key Changes
logging.config
import to manage logging configurations.LOGGING_NAME
set to "yolov5" to unify logger naming.set_logging
function to uselogging.config.dictConfig
for logging setup.🎯 Purpose & Impact
dictConfig
allows for more advanced logging customization and potential future expansion of logging capabilities.LOGGING_NAME
aids in maintaining consistent logger references across the codebase.