Reputation: 110412
Assuming that a python file is named with a .py
extension, would there ever be a reason that the module listed in the output of the logging module is not the filename itself (minus the extension)? For example:
Module (module) == run
Filename (filename) == run.py
Would be a variation of what I would get when using:
%(module)s , %(filename)s
Would there ever be a use-case where the above does not hold?
Upvotes: 5
Views: 325
Reputation: 1123970
For the logging
module, the module
string is directly derived from the filename
string:
try:
self.filename = os.path.basename(pathname)
self.module = os.path.splitext(self.filename)[0]
except (TypeError, ValueError, AttributeError):
self.filename = pathname
self.module = "Unknown module"
So, unless you are using custom logging code that alters these values on the log record after the fact, there is never a reason to see module
as anything other than the base name of the file, without the extension.
Upvotes: 5