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


Groups > comp.lang.python > #87739

Re: Root logger sanity

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'root': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'unittest': 0.09; 'def': 0.12; 'fails.': 0.16; 'logger': 0.16; 'missing?': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'skip:l 30': 0.24; 'logging': 0.26; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'am,': 0.29; 'code': 0.31; 'assert': 0.31; 'class': 0.32; 'supposed': 0.32; 'url:python': 0.33; 'url:org': 0.36; 'should': 0.36; 'two': 0.37; 'challenging': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'skip:u 10': 0.60; 'skip:t 30': 0.61; 'email addr:gmail.com': 0.63; 'different': 0.65; 'pardon': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Root logger sanity
Date Thu, 19 Mar 2015 11:33:39 +0100
Organization None
References <5277e05b-c333-4e25-80ba-bb9cd378ca84@googlegroups.com> <550AA066.8030909@rece.vub.ac.be>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bd873a.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
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.24.1426761236.10327.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1426761236 news.xs4all.nl 2921 [2001:888:2000:d::a6]:33093
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87739

Show key headers only | View raw


Antoon Pardon wrote:

> On 03/19/2015 10:35 AM, martin.spamer@gmail.com wrote:
>> The following code is challenging my sanity, in my understanding of the
>> documentation this should pass, given that getLogger is supposed to
>> return the root logger and the root logger should be called 'root'.
> 
> Where do you get the idea that the root logger should be called 'root'?

>>> import logging
>>> logging.getLogger()
<logging.RootLogger object at 0x7fdef71a8630>
>>> _.name
'root'

The root logger is the only logger where

assert logger is logging.getLogger(logger.name)

fails. I can see that this may be a pitfall.

> AFAIU the documentation the root logger is nameless. So
> logging.getLogger() will return the root logger while
> logging.getLogger('root') will return the logger named 'root'
> 
> which are two different loggers.
> 
>>
>> https://docs.python.org/2/library/logging.html#logger-objects
>>
>> What am I missing?
>>
>>
>> from unittest import TestCase
>> import logging
>>
>> class LoggingSanityTest(TestCase):
>>
>>     def test_root_logging_sanity(self):
>>         assert logging.getLogger() == logging.getLogger('root')

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


Thread

Root logger sanity martin.spamer@gmail.com - 2015-03-19 02:35 -0700
  Re: Root logger sanity Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-03-19 11:09 +0100
  Re: Root logger sanity Peter Otten <__peter__@web.de> - 2015-03-19 11:33 +0100

csiph-web