invalid-get-logger-argument (LOG002)
Added in v0.2.0 · Related issues · View source
Derived from the flake8-logging linter.
Fix is sometimes available.
What it does
Checks for any usage of __cached__ and __file__ as an argument to
logging.getLogger().
Why is this bad?
The logging documentation recommends this pattern:
Here, __name__ is the fully qualified module name, such as foo.bar,
which is the intended format for logger names.
This rule detects probably-mistaken usage of similar module-level dunder constants:
__cached__- the pathname of the module's compiled version, such asfoo/__pycache__/bar.cpython-311.pyc.__file__- the pathname of the module, such asfoo/bar.py.
Example
Use instead:
Fix safety
This fix is always unsafe, as changing the arguments to getLogger can change the
received logger object, and thus program behavior.