Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'handler': 0.04; 'passes': 0.05; 'live?': 0.07; 'python': 0.08; 'commonly': 0.09; 'handlers': 0.09; 'subject:python': 0.10; 'cc:addr:python-list': 0.15; 'cc:name:python list': 0.16; 'chris,': 0.16; 'from:addr:vinay_sajip': 0.16; 'logger.': 0.16; 'reply- to:addr:vinay_sajip': 0.16; 'sajip': 0.16; 'simplistix': 0.16; 'subject:limitation': 0.16; 'url:simplistix': 0.16; 'vinay': 0.16; 'instance': 0.18; 'that?': 0.18; 'cheers,': 0.20; 'header:In- Reply-To:1': 0.22; '-----': 0.23; 'libraries': 0.24; 'cc:2**0': 0.25; 'cc:': 0.25; 'looks': 0.27; 'filter': 0.28; "skip:' 10": 0.29; 'cc:addr:python.org': 0.29; 'class': 0.29; 'down,': 0.30; 'pattern': 0.30; 'chris': 0.30; 'subject:?': 0.30; 'app': 0.31; 'attach': 0.32; 'cases': 0.32; 'dependent': 0.32; 'like.': 0.32; 'list': 0.32; 'it.': 0.33; 'message.': 0.33; 'match': 0.33; 'subject:': 0.34; 'from:addr:yahoo.co.uk': 0.34; 'rather': 0.34; 'certain': 0.34; 'integer': 0.34; 'root': 0.34; 'apply': 0.35; 'however,': 0.35; 'sent:': 0.36; 'uses': 0.36; 'example,': 0.36; 'passed': 0.37; 'enough': 0.37; 'getting': 0.37; 'monday,': 0.38; 'processing': 0.39; 'from:': 0.39; 'why': 0.39; 'or,': 0.39; 'subject:: ': 0.39; 'url:uk': 0.40; 'more': 0.61; 'your': 0.61; 'url:co': 0.63; 'levels': 0.64; 'making': 0.65; 'header:Reply- To:1': 0.71; 'received:bullet.mail.ukl.yahoo.com': 0.80; '13:10': 0.84; '2012,': 0.84; 'received:217.146.183.180': 0.84; 'reply- to:addr:yahoo.co.uk': 0.91; 'received:217.146.183': 0.95 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 344126.12382.bm@omp1039.mail.ukl.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1326726505; bh=lfnCZvmmAh1vo7zb9LZ71xaoLIdlOpUjFdrJto2v/rU=; 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=DR3vKjq6HwCmOyF1giQxz0BsJiRz/Gn+hxR8zvzGoec5YAuvLVO14hpVh6RmvLWxDDLqhsguRjEXD+7db7eXCNhx4dDJieXk/xRWaXxi+kfX9H55vLGBMhHare4tGdJ+sjRaPynW7KYopAqwZPo+xCukopcSHQBg9txftf10/Ag= 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=jvqn+kHXHART0Jkg7tYL+spq0AkH558NTUEVmlU/7sEu2f+SWti14X9HFotc5CJgxT2V2b6HHKS/FeQjzf1Mga/UPt15tCIkylXkfV6XFePHmkL0WdJ8C4NxzIoEjuFyIMDj68zkEf+o4IdxLQv08QBPosyJjlnQXqQ/yJkYPqY=; X-YMail-OSG: UDvGqEwVM1lObUcQSnvyFLpHpR0ym1glzJJVW34wVBhhxpO ECf8lWo5mp_eptvqmvuks3HgiU70xKapFMCBozHchhod5WZiPMxEDVM0SN1H NvrhGVFI3oB7pAU4rn5Q_LEVSNg3teoLPY99xDDAkmiJf7lpbKn43Fe3QDb_ KAWUK06FNbX6JXRiSHyUT6rmNeQTPHEJphqcIobW_FfAhrvDSSLaFlWkYXzq MeapebK3OYauEYT3PhuhUKkSMQc3WAR5x773xf5PrxfBFbfXlCY.1CD_BL1J 9yHECa1a.dbAeCqkzGCWSb6me3h0hTG3lIBB5tKjJrfmirEGiW0vOognt1vj bJdouvA6p12U.MfX40DBUwgAx8VXcRA18Klw8KoqRMnhMCgc5O7pFFxAmT3n V.sOcyyDW6ML5_8XV9r7o56nzy8._TdUQ8aUir55cMrk4StunKbD9Eo9sjui My09yQerKQGVXnafN27iZXs264Fekz.JYuFyAlEjfdckmDE2a8NjmD1g- X-Mailer: YahooMailWebService/0.8.115.331698 References: <4F1421C3.6060806@simplistix.co.uk> Date: Mon, 16 Jan 2012 15:08:25 +0000 (GMT) From: Vinay Sajip Subject: Re: python loggingL filter limitation, looks intentional? To: Chris Withers In-Reply-To: <4F1421C3.6060806@simplistix.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Python List 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326726512 news.xs4all.nl 6955 [2001:888:2000:d::a6]:44993 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19040 Hi Chris,=0A=0AFiltering is intended to be for cases where integer level-ba= sed filtering is insufficient; hence it applies to individual loggers and h= andlers, just as the integer levels do.=A0 You are right that you would nee= d to add a filter to all of the loggers where you want it to apply, or to a= ll of the handlers where you want it to apply. However, if you find your us= age pattern occurring very commonly in your applications, it's easy enough = to create a DelegatingHandler handler class which passes its events on to a= ny number of handlers you like. You can then apply the filter you want to a= n instance of this handler, which you attach to your root logger.=0ARegards= ,=0A=0A=0AVinay Sajip=0A=0A=0A----- Original Message -----=0A> From: Chris = Withers =0A> To: Vinay Sajip =0A> Cc: Python List =0A> Sent: Monday, 16 Janua= ry 2012, 13:10=0A> Subject: python loggingL filter limitation, looks intent= ional?=0A> =0A> Hi Vinay,=0A> =0A> It looks like this was intentional, so w= hy was it decided that filters would =0A> only be passed messages logged to= the logger they're attached to rather than =0A> the all messages that end = up getting passed to logger?=0A> =0A> For example, an app and the libraries= it uses log to 'some.db.driver', =0A> 'some.lib' and 'myapp'.=0A> =0A> The= root logger has a number of handlers attached to it.=0A> =0A> I want to wr= ite a filter that adjusts, up or down, the level of certain messages =0A> l= ogged based on a regex match of their message.=0A> =0A> If I understand cor= rectly, I have to add my filter to all of the loggers above, =0A> rather th= an just the root logger where my handlers live?=0A> =0A> Or, alternatively,= add the filter to all of the root handlers, thereby making =0A> the config= uration of those handlers and/or more dependent on each other.=0A> =0A> Why= is that?=0A> =0A> cheers,=0A> =0A> Chris=0A> =0A> -- Simplistix - Content = Management, Batch Processing & Python Consulting=0A> =A0 =A0 =A0 =A0 =A0 = =A0 - http://www.simplistix.co.uk=0A>