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


Groups > comp.lang.python > #4954

Re: A suggestion for an easy logger

From Vinay Sajip <vinay_sajip@yahoo.co.uk>
Newsgroups comp.lang.python
Subject Re: A suggestion for an easy logger
Date 2011-05-08 05:31 -0700
Organization http://groups.google.com
Message-ID <bac2afe8-42e8-4eca-9782-85ef58909c00@k22g2000yqh.googlegroups.com> (permalink)
References (1 earlier) <f0ca57e6-e93c-48ce-9291-3efbd44f3c3a@z13g2000yqg.googlegroups.com> <iq57ci$562$1@speranza.aioe.org> <iq5cev$efk$1@speranza.aioe.org> <06491221-3c68-48ca-ad9c-9cb8c171b1ed@w24g2000yqb.googlegroups.com> <iq5ubq$moi$1@speranza.aioe.org>

Show all headers | View raw


On May 8, 12:21 pm, TheSaint <nob...@nowhere.net.no> wrote:


> First I didn't espect to see much more than my message. I agree that I'm
> very new to the module

You could do

logging.basicConfig(level=logging.DEBUG, format='%(message)s')

to get just the message.

> Second the will terminator appear only to real stdout, or am I doing
> something incorrect?

The terminator is an attribute on the StreamHandler instance, so works
with whatever stream the handler is using. You can't use basicConfig()
directly, if you want to configure the terminator - instead, use
something like

sh = logging.StreamHandler(sys.stdout)
sh.terminator = ''
logging.getLogger().addHandler(sh)

but be sure to execute this code one time only, or you will get
multiple identical messages for a single logging call.

Regards,

Vinay Sajip

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


Thread

Re: A suggestion for an easy logger mcilrain <noah.mcilraith@gmail.com> - 2011-05-07 17:00 -0700
  Re: A suggestion for an easy logger Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2011-05-07 19:27 -0700
    Re: A suggestion for an easy logger TheSaint <nobody@nowhere.net.no> - 2011-05-08 12:49 +0800
      Re: A suggestion for an easy logger TheSaint <nobody@nowhere.net.no> - 2011-05-08 14:15 +0800
        Re: A suggestion for an easy logger Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2011-05-08 03:26 -0700
          Re: A suggestion for an easy logger TheSaint <nobody@nowhere.net.no> - 2011-05-08 19:21 +0800
            Re: A suggestion for an easy logger Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2011-05-08 05:31 -0700
              Re: A suggestion for an easy logger TheSaint <nobody@nowhere.net.no> - 2011-05-09 22:53 +0800
                Re: A suggestion for an easy logger Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2011-05-09 09:34 -0700
                Re: A suggestion for an easy logger TheSaint <nobody@nowhere.net.no> - 2011-05-10 18:06 +0800

csiph-web