Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'api.': 0.05; '"""': 0.07; 'args': 0.07; 'wednesday,': 0.07; 'string': 0.09; '*args,': 0.09; 'arguments': 0.09; 'converted': 0.09; 'formatting': 0.09; 'indication': 0.09; 'msg': 0.09; 'def': 0.12; 'assume': 0.14; '*args': 0.16; 'args,': 0.16; 'emit': 0.16; 'line).': 0.16; 'logger': 0.16; 'self.args': 0.16; 'subject:Logging': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'feb': 0.22; 'appears': 0.22; 'error': 0.23; "shouldn't": 0.24; 'skip:" 40': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'noted': 0.31; 'file': 0.32; '(most': 0.33; 'comment': 0.34; 'subject:with': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'method': 0.36; 'level': 0.37; 'performance': 0.37; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'ian': 0.60; 'logged': 0.60; '2015': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=5VVgwTRaZJEXpVG6DfHqKXKKjG3rYEutir0Sm7ByOc4=; b=mfwx6Cbh4onVUhB2gPe1TuNKuObkRIP3LlR5S53Dzl2JjFIi4ADGFsuE9MHZJdkQsb cxrL/hdG+F/bq0AN4kRbl8bQiq9Kdux4IVulZKoDgn70Pt16nK7wMBxU992PD+tLhAli y8JgZkdrQy2pv5BZVz5mMEDOOPGzgsxr/k7nU4wDJwWBlEa8Xs8pLkppvWZRAIRUnc7S QxSlDu2CaBRsMhH7y8FAZeI2rmycE1zKtfigxixuCJrJFOx4mEkghY1MtsP88c5dR3Z0 4cw5aXIE7ga2vqwHCIcT0JUxah5aP7NiAebG+X3LGKnBilK+i0UlTAFeEst9218RCmDK 04lw== X-Received: by 10.66.221.194 with SMTP id qg2mr15382145pac.106.1424423840016; Fri, 20 Feb 2015 01:17:20 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <674667d9-a720-4d3f-979b-3ea2c2267e8b@googlegroups.com> References: <24fc6e1c-1db3-41e0-84df-18b0ca5a8c69@googlegroups.com> <674667d9-a720-4d3f-979b-3ea2c2267e8b@googlegroups.com> From: Ian Kelly Date: Fri, 20 Feb 2015 02:16:39 -0700 Subject: Re: Logging with Custom Levels not working To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424424329 news.xs4all.nl 2839 [2001:888:2000:d::a6]:39377 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85960 On Thu, Feb 19, 2015 at 11:16 AM, Didymus 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).