You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes modules are copy-pasta'd to create new ones, leading to the getLogger() preamble being duplicated but not used:
importlogginglogger=logging.getLogger(__name__) # never used
These unused loggers don’t take long to construct, about 1µs, but they do live forever in the logging tree (seen with logging.Logger.manager.loggerDict), wasting memory and potentially hampering efforts to debug logging.
Let’s detect and flag module-level loggers that aren’t used anywhere in their file.
(I’ve found such cases before with this regular expression: (?s)^logger = (?!.*?logger.*$))
The text was updated successfully, but these errors were encountered:
Description
Sometimes modules are copy-pasta'd to create new ones, leading to the
getLogger()
preamble being duplicated but not used:These unused loggers don’t take long to construct, about 1µs, but they do live forever in the logging tree (seen with
logging.Logger.manager.loggerDict
), wasting memory and potentially hampering efforts to debug logging.Let’s detect and flag module-level loggers that aren’t used anywhere in their file.
(I’ve found such cases before with this regular expression:
(?s)^logger = (?!.*?logger.*$)
)The text was updated successfully, but these errors were encountered: