Message348901
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. |
|
Date |
User |
Action |
Args |
2019-08-02 13:55:30 | João Eiras | set | recipients:
+ João Eiras, vinay.sajip, cool-RR |
2019-08-02 13:55:30 | João Eiras | set | messageid: <1564754130.06.0.511575065782.issue29036@roundup.psfhosted.org> |
2019-08-02 13:55:30 | João Eiras | link | issue29036 messages |
2019-08-02 13:55:29 | João Eiras | create | |
|