Logging with Custom Levels not working

Ian Kelly ian.g.kelly at gmail.com
Wed Feb 18 15:15:23 EST 2015


On Wed, Feb 18, 2015 at 6:49 AM, Didymus <lynto28 at gmail.com> 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.



More information about the Python-list mailing list