Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'skip': 0.04; 'subclass': 0.09; 'received:209.85.214.174': 0.13; '[errno': 0.16; 'received:10.60': 0.16; 'subject:logging': 0.16; 'try/except': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'header:In- Reply-To:1': 0.22; 'cc:2**0': 0.26; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.29; 'server': 0.30; 'there': 0.33; 'jason': 0.34; 'connection': 0.36; 'received:209.85.214': 0.36; 'http': 0.37; 'received:google.com': 0.37; 'happens': 0.38; 'received:209.85': 0.38; 'except': 0.39; 'received:209': 0.39; 'header:Received:6': 0.61; 'http:': 0.84 Received-SPF: pass (google.com: domain of arnodel@gmail.com designates 10.60.1.4 as permitted sender) client-ip=10.60.1.4; Authentication-Results: mr.google.com; spf=pass (google.com: domain of arnodel@gmail.com designates 10.60.1.4 as permitted sender) smtp.mail=arnodel@gmail.com; dkim=pass header.i=arnodel@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+oaR6DEX64dhK/LXIgGsR4yWoTN9z0SfvGPhYNVqw8I=; b=Lk73RYxxCWNnHMsA7g/IPyIbeHor3JuyI7KbYMDa0hUzr6AHu6gBh+OSGSKjP0EfZE PUrphQxFV/fGbU3UxmeJdMCNkifYodtZRBBJSTg0DXS0M0UZgNmu8SbMiLubtPEldD9V 7zy4jbrFO9d4GOZptu/6gJ2gbDsCRCME4ioo8= MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 20 Feb 2012 16:16:42 +0000 Subject: Re: HTTP logging From: Arnaud Delobelle To: Jason Friedman Content-Type: text/plain; charset=UTF-8 Cc: python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329754605 news.xs4all.nl 6941 [2001:888:2000:d::a6]:55467 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20625 On 20 February 2012 16:03, Jason Friedman wrote: > I am logging to HTTP: > > logger.addHandler(logging.handlers.HTTPHandler(host, url)) > > Works great, except if my HTTP server happens to be unavailable: > > socket.error: [Errno 111] Connection refused > > Other than wrapping all my logger.log() calls in try/except blocks, is > there a way to skip logging to the HTTPhandler if the HTTP server is > unavailable? Here's one: subclass HTTPHandler :) -- Arnaud