Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'handler': 0.04; 'versions.': 0.07; 'python': 0.08; 'alters': 0.09; 'bug,': 0.09; "everyone's": 0.09; 'handlers': 0.09; 'subclass': 0.09; 'url:github': 0.09; 'subject:python': 0.10; ';-)': 0.12; 'library': 0.13; 'classes,': 0.13; 'cc:addr:python-list': 0.15; 'examples': 0.15; 'bug...': 0.16; 'code?': 0.16; 'earlier,': 0.16; 'flags.': 0.16; 'from:addr:vinay_sajip': 0.16; 'hacks': 0.16; 'handlers.': 0.16; 'maybe,': 0.16; 'occasionally': 0.16; 'overflow': 0.16; 'reply-to:addr:vinay_sajip': 0.16; 'sajip': 0.16; 'scenarios': 0.16; 'subject:limitation': 0.16; 'subject:logging': 0.16; 'upset': 0.16; 'versa,': 0.16; 'vinay': 0.16; "haven't": 0.20; "doesn't": 0.22; 'assume': 0.22; 'header :In-Reply-To:1': 0.22; 'pieces': 0.23; 'unlikely': 0.23; 'library.': 0.24; 'stack': 0.24; 'cc:2**0': 0.25; 'code': 0.25; 'classes': 0.26; '"the': 0.26; 'looks': 0.27; 'asking': 0.27; 'filter': 0.28; 'true,': 0.28; 'cc:addr:python.org': 0.29; '(since': 0.30; 'config': 0.30; 'differently': 0.30; 'filters,': 0.30; 'fork': 0.30; 'chris': 0.30; 'error': 0.30; 'subject:?': 0.30; '(e.g.': 0.30; 'quite': 0.31; "i've": 0.31; 'anyone': 0.31; 'attach': 0.32; 'cases': 0.32; 'suggested': 0.32; "can't": 0.32; "isn't": 0.32; 'sort': 0.32; 'agree': 0.33; 'there': 0.33; 'this.': 0.33; 'from:addr:yahoo.co.uk': 0.34; 'rather': 0.34; 'certain': 0.34; 'setting': 0.34; 'hacking': 0.34; 'requirement.': 0.34; 'things': 0.35; 'vice': 0.35; 'especially': 0.35; "i'll": 0.35; 'skip:" 10': 0.36; 'but': 0.37; 'using': 0.37; 'useful': 0.38; 'third': 0.38; 'think': 0.38; 'easier': 0.38; 'should': 0.38; 'from:': 0.39; 'point': 0.39; 'being': 0.39; 'help': 0.39; 'called': 0.39; 'subject:: ': 0.39; 'change': 0.40; 'might': 0.40; 'packages': 0.40; 'according': 0.60; 'design': 0.61; 'more': 0.61; 'custom': 0.61; 'meet': 0.61; 'your': 0.61; 'applying': 0.62; 'view': 0.64; 'believe': 0.65; 'decision,': 0.67; 'header:Reply- To:1': 0.71; 'want,': 0.71; 'design.': 0.73; 'numerous': 0.73; 'period.': 0.73; 'received:bullet.mail.ukl.yahoo.com': 0.80; 'audiences': 0.84; 'composing': 0.84; 'termed': 0.84; 'valid,': 0.84; '3.3': 0.91; 'achievable': 0.91; 'reply- to:addr:yahoo.co.uk': 0.91; 'technique': 0.93; 'received:217.146.183': 0.95 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 664320.76964.bm@omp1035.mail.ukl.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1326797302; bh=u5dw+gzNv1pqPPEYhTy2fRgeT+YxlZT8S/VdRq49cmc=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=bdj810kI94IWOQ05RmVFmENExFdlLdyErdyZo9jtf/N06tbC59QynxBCpCxStkKrUINZDrgtnQhtAB84yjtm9LFsdJKRAj0GQ7I28y8BHu/fmTUXQiyVAdkhAdSgj6GZ2MuA4ONwrCXoaZ8D83Ki9GqRsEeo4ys8HllmGVVUbf4= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=TVNiW+rSnuluxFUhRJhpgr5ADcILLihJnXS/ho062Yn0TpCL6BATueSSg800D2GzcsElbqjlpOdpBdZRLJ8vpSsdubXNhEjX9HDL/O2Pg/r3GaA38ZspGywEJ3IGdl4VbzxMUyQRqaksxkLWby9sqJ2cwJ+64sN8S4C/zI2Fed0=; X-YMail-OSG: wDbqO8MVM1lScsE_7ujGFuNQaXSMhC6FvZRFn3qcFsXnARl vuj4ufixVDt3dfI_3S9JHHk1v_2.GMoc0i17jItHv5eYTl1ItA0vKg5bZrdd 0Ckj7wIhGbSK0IbcSxIY0QaLePtuza7skdU5PvfOyZBsacsG1bIAthXb9amG 3fXW_NUJ0uI6n3Vh3iMXlebGMdx.xQBukdt5oH8PEVHzV4v4oga_fY8gnfal K9wsZWfbBQX4ZTu9cp9hNEU9LR3EVb8d_RG6NJyby7.YMNbOr1dqdckzbVQH gayng7P2uQKG8iB7_7plDzQWNTtHSJ25nPptvqQ0Thow170CNz6SfGmv.qgH 126ug2RFN0YSmg4f_aDMniIiLUGks10lRTRLcyN18SFpnlhIVlhTI3nimCs5 3ZgWmSvnJZ1hH5yclu2KIWRcByGuQ77IoBRP5z97Vf6id1d_nMGUuGLWLjvA ZMc3tdSCHdKTB_i6KEMlUcF_tbAFft4He5Q_MdMguN0p1HwE5Id.d X-Mailer: YahooMailWebService/0.8.115.331698 References: <4F1421C3.6060806@simplistix.co.uk> <1326726505.66259.YahooMailNeo@web25803.mail.ukl.yahoo.com> <4F146EFD.8090102@simplistix.co.uk> <1326756115.24713.YahooMailNeo@web25806.mail.ukl.yahoo.com> <4F151017.6020201@simplistix.co.uk> Date: Tue, 17 Jan 2012 10:48:22 +0000 (GMT) From: Vinay Sajip Subject: Re: python logging filter limitation, looks intentional? To: Chris Withers In-Reply-To: <4F151017.6020201@simplistix.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Vinay Sajip 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326797309 news.xs4all.nl 6870 [2001:888:2000:d::a6]:47668 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19056 > From: Chris Withers =0A=0A> How breaking code? Co= nfiguration, maybe, but I can't see anyone being upset =0A> that filtering = would begin working "the same as everything else".=0A> This just feels like= a bug...=0A=0AWell, it means that filters that don't get called now would = get called - and that's a change in behaviour.=0A=0AIt's not a bug, because= it's like that by design. I understand that you don't agree with that part= icular design decision, but it's out there now. What you're asking for isn'= t unreasonable, but not achievable without a change in behaviour. I don't w= ant people to have to code differently for Python 3.3 and for older version= s.=0A=A0=0A> Actually, the filter I want to work on (log_nerf) is precisely= for 3rd party =0A> libraries; if a library author thinks a message should = be error but you think it =0A> should be debug, and vice versa, having a fi= lter that alters the level is the =0A> only way to sort things out without = hacking the 3rd party library. I've also =0A> seen this technique used succ= essfully where the filter looks to a database for =0A> config and nerfs mes= sages during a certain time period.=0A=0AOkay,=A0 then applying a filter on= handlers is a way of achieving this.=0A=0A> Again, this doesn't help if th= e __name__-ish loggers are in third party =0A> packages that you don't want= to have to fork ;-)=0A=0ATrue, but as I said earlier, you can attach a fil= ter to your handlers. It's rather unlikely that you would have more than ha= lf-a-dozen handlers (since handlers ~=3D potential audiences for log events= ), but even so, I can't believe it's especially onerous to set up filter co= nfiguration for those handlers - and even easier if you add a DelegatingHan= dler to the mix. In https://gist.github.com/1623702 I've shown a Delegating= Handler; it's quite short.=0A=A0=0A> Both use cases are valid, and a Delega= tingHandler just feels like a hack to work =0A> around a deficiency in the = framework...=0A=0ARather, the approach I've taken is not to assume I'll mee= t everyone's needs out of the box, but that the right pieces are in place f= or people to use logging in useful ways in scenarios that I haven't thought= of - which shortcomings might well be termed "deficiencies" according to y= our point of view - by deriving and overriding classes, or by composing usi= ng filters, or setting module-level flags. There are numerous examples on e= .g. Stack Overflow where a small amount of customisation (e.g. a custom han= dler like DelegatingHandler) has been suggested to meet a specific user req= uirement. I don't think of these as hacks - I occasionally have to subclass= stdlib classes in other areas to get the behaviour I want, and that's part= and parcel of having OO at your disposal.=0A=0ARegards,=0A=0AVinay Sajip= =0A