[Zope-dev] WSGI access log user info howto?

Roger Ineichen dev at projekt01.ch
Tue Mar 31 21:30:25 EDT 2009


Hi all

Shane,
any idea about the following which whould also
affect the zope.pipeline or the zope.publisher refactoring?

I need some advice for the access log topic in wsgi.


The zope http server logs access in zope.publisher.http
like:

def setPrincipal(self, principal):
    'See IPublicationRequest'
    super(HTTPRequest, self).setPrincipal(principal)
    logging_info = ILoggingInfo(principal, None)
    if logging_info is None:
        message = '-'
    else:
        message = logging_info.getLogMessage()
    self.response.authUser = message

This means there is a ILoggingInfo adapter which returns
a simple string. ASCII and no space are preffered because
the standard access log format uses space aas delimiter.
And access lgo fiels are not unicode.

Of corse the ILoggingInfo adapter is responsible for 
choose the right format for each project. A default
is configured in zope.publisher.principallogging
PrincipalLogging

Now to the question.

In the latest checkins there was a access log part
implemented. It doesn't use the ILoggingInfo adapter and
is exposing the user login which is a part of the security
credential. This get already released. (not good)

Is there a standard how WSGI apps will log user info in
access logs? I guess not, right?

Does someone have a good idea how we should implement
user access info for access logs in zope.app.wasg?

If not, I propose the following:

logging_info = ILoggingInfo(request.principal, None)
if logging_info is None:
    message = '-'
else:
    message = logging_info.getLogMessage()
environ['wsgi.logging_info'] = message


- this will set a ``wsgi.logging_info``  environ
  variable (or is there already a standard name)?

- it uses the ILoggingInfo adapter which let us use
  different kind of access log info strategies in 
  custom projects. By default we should use the 
  PrincipalLogging adapter form zope.publisher.principallogging.

Does anybody have a better idea how we can make the user
info available for the access log?

Alex whould this fit for you?


Regards
Roger Ineichen
_____________________________
END OF MESSAGE



More information about the Zope-Dev mailing list