This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author João Eiras
Recipients João Eiras, cool-RR, vinay.sajip
Date 2019-08-02.13:55:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1564754130.06.0.511575065782.issue29036@roundup.psfhosted.org>
In-reply-to
Content
Hi.

I ask for this to be reconsidered. The "recommended" approach of using "getLogger(__name__)" comes with some downsides.

In my projects I often have many many files (in one particularly I have hundreds) and creating Logger object for each and every file, so LogRecord.name is correct is burdensome, litters the code and forces to add a global variable to the file. So, the easy approach we took was to use using logging.log(...) everywhere.

I've also seen code elsewhere where it is not guaranteed that "getLogger(__name__)" is called with the module __name__, but with some other string.

Or I've seen code where there is a shared Logger() created in some config.py that is then imported into other files.

Overall, relying on LogRecord.name is error prone and requires adding more code.

I checked the logging module. The findCaller() function could easily just poke frame.f_globals.get("__name__") to get the module name, and propagate that to the LogRecord.

It's a simple addition. I can make a PR so you can comment further there. The name of the property would be LogRecord.fullModule.

Thank you.
History
Date User Action Args
2019-08-02 13:55:30João Eirassetrecipients: + João Eiras, vinay.sajip, cool-RR
2019-08-02 13:55:30João Eirassetmessageid: <1564754130.06.0.511575065782.issue29036@roundup.psfhosted.org>
2019-08-02 13:55:30João Eiraslinkissue29036 messages
2019-08-02 13:55:29João Eirascreate