On Sun, Jun 06, 2010 at 03:48:02PM +0100, Enrico Zini wrote:

> Just for fun, if you use wsgiref's server, it uses BaseHTTPServer, and
> look at this:
>     From /usr/lib/python2.5/BaseHTTPServer.py:
>     def log_message(self, format, *args):
[...]
>         sys.stderr.write("%s - - [%s] %s\n" %
>                          (self.address_string(),
>                           self.log_date_time_string(),
>                           format%args))
> 
> That is, in the standard library they have a logging module, and they
> don't even use it in the http server they ship with the standard
> library.

Just for the record, here is the gist on how to silence that from
Bottle:

class WSGIRefServer(ServerAdapter):
    def run(self, handler): # pragma: no cover
        from wsgiref.simple_server import make_server, WSGIRequestHandler
        class QuietHandler(WSGIRequestHandler):
            def log_request(*args, **kw):
                pass
        srv = make_server(self.host, self.port, handler, 
handler_class=QuietHandler)
        srv.serve_forever()

Obviously instead of pass one could choose to log properly, but I just
want it damn quiet, so that is my code.


Ciao,

Enrico

-- 
GPG key: 4096R/E7AD5568 2009-05-08 Enrico Zini <[email protected]>

Attachment: signature.asc
Description: Digital signature

Reply via email to