← Back to team overview

openstack team mailing list archive

Bark logging middleware

 

I have just completed writing a piece of middleware for logging requests
in WSGI stacks.  I have dubbed this useful piece of code, "Bark," and it
is available on PyPi.  Here are the links:

      * http://pypi.python.org/pypi/bark
      * https://github.com/klmitch/bark

I've written an extensive README describing what Bark does and how it
does it, but here's a quick summary:

Bark is a logging middleware.  That is, you place it into your WSGI
pipeline (typically at the head of the pipeline, rather than close to
the application at the tail) and define one or more log streams.  Each
log stream is configured with an Apache-compatible format string.  Log
streams can send the formatted log messages to files, syslog, TCP or UDP
sockets, even email.  Bark is also easily extensible; it is possible to
add both new format string conversions and log stream types by simply
defining new entry points.

Why use Bark?  Bark can be used with any WSGI application (not just
nova) and can log virtually any information associated with the request,
and do it independently of normal application logging.  Moreover, since
the format strings are Apache-compatible, it should be possible to use
any tool designed to analyze Apache logs with Bark-generated log files.
Bark also implements proxy validation, to allow the proper originating
IP address of a client to be recorded.

Caveats: Bark can only log data provided by the underlying WSGI
implementation.  For instance, the normal WSGI server used by Nova makes
the remote IP address available in the REMOTE_ADDR environment variable,
but the port number is not made available (Bark expects it to be placed
in REMOTE_PORT if available).  Also, certain Apache conversions and
modifiers don't make sense for Bark (they are ignored for
compatibility).

For a full write-up, see the README, available at:

        http://pypi.python.org/pypi/bark
-- 
Kevin L. Mitchell <kevin.mitchell@xxxxxxxxxxxxx>