From: richard Date: Sun, 15 Feb 2004 21:44:02 +0000 (+0000) Subject: safer logging from HTTP server (sf bug 896917 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5470c20b152a21b40f163fecda96bed4525f9e1c;p=roundup.git safer logging from HTTP server (sf bug 896917 git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2088 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 233b45d..490c048 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -86,6 +86,7 @@ Fixed: - use supplied content-type on file uploads before trying filename) - fixed roundup-reminder script to use default schema (thanks Klamer Schutte) - fixed edit action / parsePropsFromForm to handle index-page edits better +- safer logging from HTTP server (sf bug 896917) 2003-12-17 0.6.4 diff --git a/roundup/scripts/roundup_server.py b/roundup/scripts/roundup_server.py index 6f58a60..c40a71c 100644 --- a/roundup/scripts/roundup_server.py +++ b/roundup/scripts/roundup_server.py @@ -17,7 +17,7 @@ """Command-line script that runs a server over roundup.cgi.client. -$Id: roundup_server.py,v 1.37 2004-02-11 23:55:10 richard Exp $ +$Id: roundup_server.py,v 1.38 2004-02-15 21:44:02 richard Exp $ """ __docformat__ = 'restructuredtext' @@ -70,6 +70,17 @@ AoFAtVo1m825XO7hSODOYrH4kHbxxGAwwODBGI/H6DBs5LNara7yl8slGjIcDsHpdrunU6PRCAP2 r3fPdUcIYeyEfLSAJ0LeAUZHCAt8Al/8/kLIEWDB5YDj0wm8fAP6fVfo '''.strip())) +class RoundupHTTPServer(SafeLogging, BaseHTTPServer.HTTPServer): + def log_message(self, format, *args): + ''' Try to use the logging package, otherwise *safely* log to + stderr. + ''' + try: + BaseHTTPServer.HTTPServer.log_message(self, format, *args) + except IOError: + # stderr is no longer viable, we can't log + pass + class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): TRACKER_HOMES = TRACKER_HOMES ROUNDUP_USER = ROUNDUP_USER @@ -229,8 +240,7 @@ else: SvcShutdown = "ServiceShutdown" - class RoundupService(win32serviceutil.ServiceFramework, - BaseHTTPServer.HTTPServer): + class RoundupService(win32serviceutil.ServiceFramework, RoundupHTTPServer): ''' A Roundup standalone server for Win32 by Ewout Prangsma ''' _svc_name_ = "Roundup Bug Tracker" @@ -242,7 +252,7 @@ else: # appending, unbuffered sys.stdout = sys.stderr = open(LOGFILE, 'a', 0) win32serviceutil.ServiceFramework.__init__(self, args) - BaseHTTPServer.HTTPServer.__init__(self, self.address, + RoundupHTTPServer.__init__(self, self.address, RoundupRequestHandler) # Create the necessary NT Event synchronization objects... @@ -435,7 +445,7 @@ def run(port=PORT, success_message=None): # 1024 if started as root address = (hostname, port) try: - httpd = BaseHTTPServer.HTTPServer(address, RoundupRequestHandler) + httpd = RoundupHTTPServer(address, RoundupRequestHandler) except socket.error, e: if e[0] == errno.EADDRINUSE: raise socket.error, \