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??

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'root': 0.05; '"""': 0.07; '*args,': 0.09; 'hierarchical': 0.09; 'subject:module': 0.09; 'def': 0.12; '"module"': 0.16; 'args,': 0.16; 'attribute,': 0.16; 'logger': 0.16; 'pythonic': 0.16; 'subject:Logging': 0.16; 'wrote:': 0.18; 'module': 0.19; 'stack': 0.19; 'email addr:gmail.com&gt;': 0.22; 'module,': 0.24; '&gt;': 0.26; 'define': 0.26; 'logging': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'wondering': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'this.': 0.32; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'level': 0.37; 'performance': 0.37; 'skip:& 10': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'logged': 0.60; 'name': 0.63; 'believe': 0.68; 'mar': 0.68; '2015': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=HcXXvaLSB+HGPzkjCWmSamq+seOCmhPWuKmrCXuHEXo=; b=S/PM7tPSLcapWZvPEHy2IPk0Cy2ynYN/57mGvNDKo6Ut8jsP5yvbJTgH2f1iyLzzmK jeJ4cw5RFfWVqJ7hCQti0ynU03xA9VzoTm1ec0pkmQvVCUJzQWgEQoaTQlAoIXJLD/ku mOOH/b2IPN2KFUNGRtE2+vLeASpFw852f72MX38XRIkarR+3QVu9db7w6zix1q6botQI GkPnScNZQNhZf6aHpSdly5FiqqnYg94Acbg0EZYozImIjzyVjYawEI1QuIfj6StyIMX3 OXEKpAZ+sLv0kp+M5dcdO0KPs/MJubLd10bHApToOrYWCUNJk+9ku180Tmp5bk0G7MGw xCzw==
MIME-Version 1.0
X-Received by 10.68.65.75 with SMTP id v11mr20376532pbs.10.1425396645514; Tue, 03 Mar 2015 07:30:45 -0800 (PST)
In-Reply-To <aada4054-154b-49bb-89e3-7650421b1a40@googlegroups.com>
References <6676f6f6-94bf-4ed9-9a09-46beb4317e6c@googlegroups.com> <mailman.20.1425394911.21433.python-list@python.org> <aada4054-154b-49bb-89e3-7650421b1a40@googlegroups.com>
Date Tue, 3 Mar 2015 08:30:45 -0700
Subject Re: Logging custom level not print module properly??
From Ian Kelly <ian.g.kelly@gmail.com>
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=001a1138029eb85554051064040e
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.21.1425396648.21433.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1425396648 news.xs4all.nl 2849 [2001:888:2000:d::a6]:34172
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86850

Show key headers only | 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