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


Groups > comp.lang.python > #35780

Re: Facing issue with Python loggin logger for printing object value

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: Facing issue with Python loggin logger for printing object value
Date 2012-12-29 16:22 -0500
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-37DC28.16221629122012@news.panix.com> (permalink)
References (1 earlier) <50DF1D48.2060507@davea.name> <CAJ2vgs5j3+HYNWBd-3BN6p9hyDMG_5MmOrCKfodcMNzTg-OQUg@mail.gmail.com> <50DF241B.5070007@davea.name> <CAJ2vgs7L5Ye2WsP55EzQQm4iHVNvPH6-dieJGSrHpjtaOThVog@mail.gmail.com> <mailman.1442.1356814265.29569.python-list@python.org>

Show all headers | View raw


In article <mailman.1442.1356814265.29569.python-list@python.org>,
 Morten Engvoldsen <mortenengv@gmail.com> wrote:

> It is able to log the message with:
> logger.debug("value of payment_line is " +repr(payment_line))

As a side note, a better way to write that is

logger.debug("value of payment_line is %r", payment_line)

The difference is that the first way, repr(payment_line) is evaluated, 
and the string addition is done, before debug() is called.  Only then 
will it be decided if message should be logged, and if not, it will be 
discarded.

The second way, payment_line will just get passed to debug().  If the 
message is never logged, repr() will never get called.  Much more 
efficient that way, especially for debug calls which most of the time 
will not get logged.

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


Thread

Re: Facing issue with Python loggin logger for printing object value Morten Engvoldsen <mortenengv@gmail.com> - 2012-12-29 21:50 +0100
  Re: Facing issue with Python loggin logger for printing object value Roy Smith <roy@panix.com> - 2012-12-29 16:22 -0500

csiph-web