[Zope] Userid in Z2.log

flynt flynt@gmx.ch
Wed, 24 Oct 2001 16:10:29 +0200


Tim Cook wrote:
> 
> I didn't find where this issue has appeared in the archives but I
> thought I woould see if anyone has seen/solved it.
> 
> The userid is not logged in my Z2.log:
> Zope Version    Zope 2.3.2 (binary release, python 1.5.2,
> linux2-x86)
> Python Version  1.5.2 (#10, Dec 6 1999, 12:16:27) [GCC 2.7.2.3]
> 
> Installed products are:
> 
> BTreeFolder Product
> LocalFS
> Xron
> CookieCrumbler.
> spellchecker
> 
> I know that it was occuring before I started using CookieCrumbler
> and spellchecker.  One item in the archives indicated that it
> *may* be asociated with LocalFS.
> 
> The symptom is that I get a dash ( - ) following the IP where the
> userid should be.
> 
> Any ideas appreciated.
> 
Hi Tim,

I don't remember either, where I found it. But I use it so I can give
you the patch from my modified site:

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
                )
            )
      ...

That should do the job.


Greetings

--- Flynt