python - Why get a new logger object in each new module? -
the python logging module has common pattern (ex1, ex2) in each module new logger object each python module.
i'm not fan of blindly following patterns , understand little bit more.
why new logger object in each new module?
why not have use same root logger , configure formatter %(module)s
?
is there examples pattern necessary/needed (i.e. because of sort of performance reason[1])?
[1] in multi-threaded python program, there sort of hidden synchronization issues fixed using multiple logging objects?
each logger can configured separately. generally, module logger not configured at all in module itself. create distinct logger , use log messages of varying levels of detail. whoever uses logger decides level of messages see, send messages, , how display them. may want (debug
, up) 1 module logged file, while module may care if serious error occurs (in case want e-mailed directly them). if every module used same (root) logger, wouldn't have kind of flexibility.
Comments
Post a Comment