Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86850

Re: Logging custom level not print module properly??

References <6676f6f6-94bf-4ed9-9a09-46beb4317e6c@googlegroups.com> <mailman.20.1425394911.21433.python-list@python.org> <aada4054-154b-49bb-89e3-7650421b1a40@googlegroups.com>
Date 2015-03-03 08:30 -0700
Subject Re: Logging custom level not print module properly??
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.21.1425396648.21433.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Mar 3, 2015 8:16 AM, "Didymus" <lynto28@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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Logging custom level not print module properly?? Didymus <lynto28@gmail.com> - 2015-03-03 06:06 -0800
  Re: Logging custom level not print module properly?? Peter Otten <__peter__@web.de> - 2015-03-03 16:01 +0100
    Re: Logging custom level not print module properly?? Didymus <lynto28@gmail.com> - 2015-03-03 07:11 -0800
      Re: Logging custom level not print module properly?? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-03 08:30 -0700

csiph-web