Logging custom level not print module properly??

Ian Kelly ian.g.kelly at gmail.com
Tue Mar 3 10:30:45 EST 2015


On Mar 3, 2015 8:16 AM, "Didymus" <lynto28 at gmail.com> wrote:
> I did find that if I changed the "self.log" to "self._log" it works
correctly but gives me a pylint warning about acccess to a protected member
_log..
>
> def pwarning(self, message, *args, **kws):
>     """ Performance Warning Message Level """
>     # Yes, logger takes its '*args' as 'args'.
>     self._log(PWARNING_NUM, message, args, **kws)
>
> Still wondering what the correct Pythonic way to handle this.

I believe the common approach is to let each module define and use its own
hierarchical logger named after the module, rather than have them all share
the root logger. This way the name that is logged is based on which logger
was used for logging and doesn't rely on the "module" attribute, which is
populated through the vagaries of stack inspection.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150303/14bd0fd2/attachment.html>


More information about the Python-list mailing list