Erik Myllymaki writes:
Any easy way to add AUTHENTICATED_USER to Z2.log? I do not think so:
"Z2.log" is a very low level device (written by ZServer). "AUTHENTICATED_USER" is medium level device (defined by ZPublisher) You will at least need to modify ZServer code.... Dieter
Erik Myllymaki wrote:
Any easy way to add AUTHENTICATED_USER to Z2.log?
Hi Erik Two questions: What is the Zope version you use ? In Zope 2.4.3 the authenticated users are logged in the Z2.log. For Zope 2.3.x you have to patch http_server.py Second question is: what do you use for authentication ? I don't have the answer for CookieCrumbler, but only for basic http authentication (which is used for the basic user folder coming with Zope). Here is the answer for basic http authentication and Zope 2.3.x (I looked it up somewhere, but I do not remember anymore where and couldn't find it easily again): Go to the file *Zserver/medusa/http_server.py* and edit the method *log*. It must read like this (don't forget the import of base64 module):: ... # python modules import base64 import os import regex import re import socket import stat import string import sys import time # async modules ... ... def log (self, bytes): user_agent=self.get_header('user-agent') if not user_agent: user_agent='' referer=self.get_header('referer') if not referer: referer='' auth=self.get_header('AUTHORIZATION') name='Anonymous' if auth is not None: if string.lower(auth[:5]) == 'basic': [name,password] = string.split( base64.decodestring( string.split(auth)[-1]), ':') self.channel.server.logger.log ( self.channel.addr[0], ' - %s - [%s] "%s" %d %d "%s" "%s"\n' % ( # self.channel.addr[1], name, self.log_date_string (time.time()), self.request, self.reply_code, bytes, referer, user_agent ) ) ... Maybe this helps. --- Flynt
participants (3)
-
Dieter Maurer -
Erik Myllymaki -
flynt