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


Groups > comp.lang.python > #85960

Re: Logging with Custom Levels not working

References <24fc6e1c-1db3-41e0-84df-18b0ca5a8c69@googlegroups.com> <mailman.18834.1424290566.18130.python-list@python.org> <674667d9-a720-4d3f-979b-3ea2c2267e8b@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2015-02-20 02:16 -0700
Subject Re: Logging with Custom Levels not working
Newsgroups comp.lang.python
Message-ID <mailman.18916.1424424329.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Feb 19, 2015 at 11:16 AM, Didymus <lynto28@gmail.com> wrote:
> On Wednesday, February 18, 2015 at 3:16:40 PM UTC-5, Ian wrote:
>> > def perror(self, message, *args, **kws):
>> >     """ Performance Error Message Level """
>> >     # Yes, logger takes its '*args' as 'args'.
>> >     self._log(PERROR_NUM, message, args, **kws)
>> >
>> > logging.Logger.perror = perror
>>
>> I think you need to call self.log, not self._log. The _log method
>> appears to assume that the level check has already been performed. You
>> really shouldn't be calling it directly anyway, as the leading _ is an
>> indication that the method is not part of the public API.
>
> Yes, I had tried that and get:
>
> Logged from file log5.py, line 21
> Traceback (most recent call last):
>   File "/usr/lib64/python2.7/logging/__init__.py", line 851, in emit
>     msg = self.format(record)
>   File "/usr/lib64/python2.7/logging/__init__.py", line 724, in format
>     return fmt.format(record)
>   File "/usr/lib64/python2.7/logging/__init__.py", line 464, in format
>     record.message = record.getMessage()
>   File "/usr/lib64/python2.7/logging/__init__.py", line 328, in getMessage
>     msg = msg % self.args
> TypeError: not all arguments converted during string formatting

log and _log don't have the same function signature. Specifically, log
takes *args and _log just takes args (as noted in the comment on the
preceding line).

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


Thread

Logging with Custom Levels not working Didymus <lynto28@gmail.com> - 2015-02-18 05:49 -0800
  Re: Logging with Custom Levels not working Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-18 13:15 -0700
    Re: Logging with Custom Levels not working Didymus <lynto28@gmail.com> - 2015-02-19 10:16 -0800
      Re: Logging with Custom Levels not working Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-20 02:16 -0700
        Re: Logging with Custom Levels not working Didymus <lynto28@gmail.com> - 2015-02-20 05:29 -0800

csiph-web