Commit 6421c26b authored by Matt Behrens's avatar Matt Behrens

#185 plus fix ajung's fix for #341: repair Z2.log for [FP]CGIServer, and

give them extended log format like HTTPServer
parent 6b7842c5
...@@ -437,10 +437,14 @@ class FCGIChannel(asynchat.async_chat): ...@@ -437,10 +437,14 @@ class FCGIChannel(asynchat.async_chat):
DebugLogger.log('E', id(self)) DebugLogger.log('E', id(self))
user_agent=self.get_header('user-agent') if self.env.has_key('HTTP_USER_AGENT'):
if not user_agent: user_agent='' user_agent=self.env['HTTP_USER_AGENT']
referer=self.get_header('referer') else:
if not referer: referer='' user_agent=''
if self.env.has_key('HTTP_REFERER'):
referer=self.env['HTTP_REFERER']
else:
referer=''
if self.env.has_key('PATH_INFO'): if self.env.has_key('PATH_INFO'):
path=self.env['PATH_INFO'] path=self.env['PATH_INFO']
...@@ -453,7 +457,7 @@ class FCGIChannel(asynchat.async_chat): ...@@ -453,7 +457,7 @@ class FCGIChannel(asynchat.async_chat):
if self.addr: if self.addr:
self.server.logger.log ( self.server.logger.log (
self.addr[0], self.addr[0],
'%s - - [%s] "%s %s" %d %d' % ( '%s - - [%s] "%s %s" %d %d "%s" "%s"' % (
self.addr[1], self.addr[1],
time.strftime ( time.strftime (
'%d/%b/%Y:%H:%M:%S ', '%d/%b/%Y:%H:%M:%S ',
...@@ -466,7 +470,7 @@ class FCGIChannel(asynchat.async_chat): ...@@ -466,7 +470,7 @@ class FCGIChannel(asynchat.async_chat):
else: else:
self.server.logger.log ( self.server.logger.log (
'127.0.0.1 ', '127.0.0.1 ',
'- - [%s] "%s %s" %d %d' % ( '- - [%s] "%s %s" %d %d "%s" "%s"' % (
time.strftime ( time.strftime (
'%d/%b/%Y:%H:%M:%S ', '%d/%b/%Y:%H:%M:%S ',
time.localtime(time.time()) time.localtime(time.time())
......
...@@ -141,6 +141,15 @@ class PCGIChannel(asynchat.async_chat): ...@@ -141,6 +141,15 @@ class PCGIChannel(asynchat.async_chat):
return 1 return 1
def log_request(self, bytes): def log_request(self, bytes):
if self.env.has_key('HTTP_USER_AGENT'):
user_agent=self.env['HTTP_USER_AGENT']
else:
user_agent=''
if self.env.has_key('HTTP_REFERER'):
referer=self.env['HTTP_REFERER']
else:
referer=''
if self.env.has_key('PATH_INFO'): if self.env.has_key('PATH_INFO'):
path=self.env['PATH_INFO'] path=self.env['PATH_INFO']
else: else:
...@@ -153,24 +162,26 @@ class PCGIChannel(asynchat.async_chat): ...@@ -153,24 +162,26 @@ class PCGIChannel(asynchat.async_chat):
if addr and type(addr) is TupleType: if addr and type(addr) is TupleType:
self.server.logger.log ( self.server.logger.log (
addr[0], addr[0],
'%d - - [%s] "%s %s" %d %d' % ( '%d - - [%s] "%s %s" %d %d "%s" "%s"' % (
addr[1], addr[1],
time.strftime ( time.strftime (
'%d/%b/%Y:%H:%M:%S ', '%d/%b/%Y:%H:%M:%S ',
time.gmtime(time.time()) time.localtime(time.time())
) + tz_for_log, ) + tz_for_log,
method, path, self.reply_code, bytes method, path, self.reply_code, bytes,
referer, user_agent
) )
) )
else: else:
self.server.logger.log ( self.server.logger.log (
'127.0.0.1', '127.0.0.1',
'- - [%s] "%s %s" %d %d' % ( ' - - [%s] "%s %s" %d %d "%s" "%s"' % (
time.strftime ( time.strftime (
'%d/%b/%Y:%H:%M:%S ', '%d/%b/%Y:%H:%M:%S ',
time.gmtime(time.time()) time.gmtime(time.time())
) + tz_for_log, ) + tz_for_log,
method, path, self.reply_code, bytes method, path, self.reply_code, bytes,
referer, user_agent
) )
) )
......
...@@ -193,6 +193,9 @@ Zope Changes ...@@ -193,6 +193,9 @@ Zope Changes
(which will bail out if it doesnt get called with a tuple (which will bail out if it doesnt get called with a tuple
argument) argument)
- Collector #185, 341: PCGIServer and FCGIServer logs corrected
and now output extended information like HTTPServer does.
Zope 2.5.1 beta 1 Zope 2.5.1 beta 1
Bugs Fixed Bugs Fixed
......
...@@ -437,10 +437,14 @@ class FCGIChannel(asynchat.async_chat): ...@@ -437,10 +437,14 @@ class FCGIChannel(asynchat.async_chat):
DebugLogger.log('E', id(self)) DebugLogger.log('E', id(self))
user_agent=self.get_header('user-agent') if self.env.has_key('HTTP_USER_AGENT'):
if not user_agent: user_agent='' user_agent=self.env['HTTP_USER_AGENT']
referer=self.get_header('referer') else:
if not referer: referer='' user_agent=''
if self.env.has_key('HTTP_REFERER'):
referer=self.env['HTTP_REFERER']
else:
referer=''
if self.env.has_key('PATH_INFO'): if self.env.has_key('PATH_INFO'):
path=self.env['PATH_INFO'] path=self.env['PATH_INFO']
...@@ -453,7 +457,7 @@ class FCGIChannel(asynchat.async_chat): ...@@ -453,7 +457,7 @@ class FCGIChannel(asynchat.async_chat):
if self.addr: if self.addr:
self.server.logger.log ( self.server.logger.log (
self.addr[0], self.addr[0],
'%s - - [%s] "%s %s" %d %d' % ( '%s - - [%s] "%s %s" %d %d "%s" "%s"' % (
self.addr[1], self.addr[1],
time.strftime ( time.strftime (
'%d/%b/%Y:%H:%M:%S ', '%d/%b/%Y:%H:%M:%S ',
...@@ -466,7 +470,7 @@ class FCGIChannel(asynchat.async_chat): ...@@ -466,7 +470,7 @@ class FCGIChannel(asynchat.async_chat):
else: else:
self.server.logger.log ( self.server.logger.log (
'127.0.0.1 ', '127.0.0.1 ',
'- - [%s] "%s %s" %d %d' % ( '- - [%s] "%s %s" %d %d "%s" "%s"' % (
time.strftime ( time.strftime (
'%d/%b/%Y:%H:%M:%S ', '%d/%b/%Y:%H:%M:%S ',
time.localtime(time.time()) time.localtime(time.time())
......
...@@ -141,6 +141,15 @@ class PCGIChannel(asynchat.async_chat): ...@@ -141,6 +141,15 @@ class PCGIChannel(asynchat.async_chat):
return 1 return 1
def log_request(self, bytes): def log_request(self, bytes):
if self.env.has_key('HTTP_USER_AGENT'):
user_agent=self.env['HTTP_USER_AGENT']
else:
user_agent=''
if self.env.has_key('HTTP_REFERER'):
referer=self.env['HTTP_REFERER']
else:
referer=''
if self.env.has_key('PATH_INFO'): if self.env.has_key('PATH_INFO'):
path=self.env['PATH_INFO'] path=self.env['PATH_INFO']
else: else:
...@@ -153,24 +162,26 @@ class PCGIChannel(asynchat.async_chat): ...@@ -153,24 +162,26 @@ class PCGIChannel(asynchat.async_chat):
if addr and type(addr) is TupleType: if addr and type(addr) is TupleType:
self.server.logger.log ( self.server.logger.log (
addr[0], addr[0],
'%d - - [%s] "%s %s" %d %d' % ( '%d - - [%s] "%s %s" %d %d "%s" "%s"' % (
addr[1], addr[1],
time.strftime ( time.strftime (
'%d/%b/%Y:%H:%M:%S ', '%d/%b/%Y:%H:%M:%S ',
time.gmtime(time.time()) time.localtime(time.time())
) + tz_for_log, ) + tz_for_log,
method, path, self.reply_code, bytes method, path, self.reply_code, bytes,
referer, user_agent
) )
) )
else: else:
self.server.logger.log ( self.server.logger.log (
'127.0.0.1', '127.0.0.1',
'- - [%s] "%s %s" %d %d' % ( ' - - [%s] "%s %s" %d %d "%s" "%s"' % (
time.strftime ( time.strftime (
'%d/%b/%Y:%H:%M:%S ', '%d/%b/%Y:%H:%M:%S ',
time.gmtime(time.time()) time.gmtime(time.time())
) + tz_for_log, ) + 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