Commit 61ac6cf7 authored by Andreas Jung's avatar Andreas Jung

Collector #341: minor fixes to logging code

parent 602b73b1
......@@ -437,6 +437,23 @@ class FCGIChannel(asynchat.async_chat):
DebugLogger.log('E', id(self))
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[:6]) == 'basic ':
try: decoded=base64.decodestring(auth[6:])
except base64.binascii.Error: decoded=''
t = string.split(decoded, ':', 1)
if len(t) < 2:
name = 'Unknown (bad auth string)'
else:
name = t[0]
if self.env.has_key('PATH_INFO'):
path=self.env['PATH_INFO']
else:
......@@ -452,20 +469,22 @@ class FCGIChannel(asynchat.async_chat):
self.addr[1],
time.strftime (
'%d/%b/%Y:%H:%M:%S ',
time.gmtime(time.time())
time.localtime(time.time())
) + tz_for_log,
method, path, self.reply_code, bytes
method, path, self.reply_code, bytes,
referer, user_agent
)
)
else:
self.server.logger.log (
'127.0.0.1',
'127.0.0.1 ',
'- - [%s] "%s %s" %d %d' % (
time.strftime (
'%d/%b/%Y:%H:%M:%S ',
time.gmtime(time.time())
time.localtime(time.time())
) + tz_for_log,
method, path, self.reply_code, bytes
method, path, self.reply_code, bytes,
referer, user_agent
)
)
......
......@@ -437,6 +437,23 @@ class FCGIChannel(asynchat.async_chat):
DebugLogger.log('E', id(self))
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[:6]) == 'basic ':
try: decoded=base64.decodestring(auth[6:])
except base64.binascii.Error: decoded=''
t = string.split(decoded, ':', 1)
if len(t) < 2:
name = 'Unknown (bad auth string)'
else:
name = t[0]
if self.env.has_key('PATH_INFO'):
path=self.env['PATH_INFO']
else:
......@@ -452,20 +469,22 @@ class FCGIChannel(asynchat.async_chat):
self.addr[1],
time.strftime (
'%d/%b/%Y:%H:%M:%S ',
time.gmtime(time.time())
time.localtime(time.time())
) + tz_for_log,
method, path, self.reply_code, bytes
method, path, self.reply_code, bytes,
referer, user_agent
)
)
else:
self.server.logger.log (
'127.0.0.1',
'127.0.0.1 ',
'- - [%s] "%s %s" %d %d' % (
time.strftime (
'%d/%b/%Y:%H:%M:%S ',
time.gmtime(time.time())
time.localtime(time.time())
) + tz_for_log,
method, path, self.reply_code, bytes
method, path, self.reply_code, bytes,
referer, user_agent
)
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment