Changeset 1938
- Timestamp:
- 04/05/08 15:04:56
- Files:
-
- trunk/cherrypy/__init__.py (modified) (1 diff)
- trunk/cherrypy/_cplogging.py (modified) (3 diffs)
- trunk/cherrypy/_cprequest.py (modified) (2 diffs)
- trunk/cherrypy/_cptree.py (modified) (1 diff)
- trunk/cherrypy/_cpwsgi.py (modified) (3 diffs)
- trunk/cherrypy/lib/cptools.py (modified) (1 diff)
- trunk/cherrypy/process/plugins.py (modified) (6 diffs)
- trunk/cherrypy/process/servers.py (modified) (1 diff)
- trunk/cherrypy/process/win32.py (modified) (2 diffs)
- trunk/cherrypy/process/wspbus.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/__init__.py
r1926 r1938 401 401 log.access_file = '' 402 402 403 def _buslog(msg ):404 log.error(msg, 'ENGINE' )403 def _buslog(msg, level): 404 log.error(msg, 'ENGINE', severity=level) 405 405 engine.subscribe('log', _buslog) 406 406 trunk/cherrypy/_cplogging.py
r1873 r1938 43 43 h.release() 44 44 45 def error(self, msg='', context='', severity=logging. DEBUG, traceback=False):45 def error(self, msg='', context='', severity=logging.INFO, traceback=False): 46 46 """Write to the error log. 47 47 … … 104 104 if not h: 105 105 if stream is None: 106 stream=sys.std out106 stream=sys.stderr 107 107 h = logging.StreamHandler(stream) 108 108 h.setLevel(logging.DEBUG) … … 122 122 self._set_screen_handler(self.access_log, newvalue) 123 123 screen = property(_get_screen, _set_screen, 124 doc="If True, error and access will print to std out.")124 doc="If True, error and access will print to stderr.") 125 125 126 126 trunk/cherrypy/_cprequest.py
r1900 r1938 104 104 except: 105 105 exc = sys.exc_info()[1] 106 cherrypy.log(traceback=True )106 cherrypy.log(traceback=True, severity=40) 107 107 if exc: 108 108 raise … … 531 531 # Failure in setup, error handler or finalize. Bypass them. 532 532 # Can't use handle_error because we may not have hooks yet. 533 cherrypy.log(traceback=True )533 cherrypy.log(traceback=True, severity=40) 534 534 if self.show_tracebacks: 535 535 body = format_exc() trunk/cherrypy/_cptree.py
r1930 r1938 123 123 req.close() 124 124 except: 125 cherrypy.log(traceback=True )125 cherrypy.log(traceback=True, severity=40) 126 126 127 127 cherrypy.serving.clear() trunk/cherrypy/_cpwsgi.py
r1933 r1938 95 95 96 96 tb = _cperror.format_exc() 97 _cherrypy.log(tb )97 _cherrypy.log(tb, severity=40) 98 98 if not getattr(self.request, "show_tracebacks", True): 99 99 tb = "" … … 115 115 raise 116 116 117 _cherrypy.log(traceback=True )117 _cherrypy.log(traceback=True, severity=40) 118 118 self.close() 119 119 … … 194 194 raise 195 195 196 _cherrypy.log(traceback=True )196 _cherrypy.log(traceback=True, severity=40) 197 197 198 198 # CherryPy test suite expects bare_error body to be output, trunk/cherrypy/lib/cptools.py
r1923 r1938 290 290 def log_traceback(severity=logging.DEBUG): 291 291 """Write the last error's traceback to the cherrypy error log.""" 292 from cherrypy import _cperror 293 cherrypy.log(_cperror.format_exc(), "HTTP", severity=severity) 292 cherrypy.log("", "HTTP", severity=severity, traceback=True) 294 293 295 294 def log_request_headers(): trunk/cherrypy/process/plugins.py
r1926 r1938 128 128 if val is not None: 129 129 if pwd is None: 130 self.bus.log("pwd module not available; ignoring uid.") 130 self.bus.log("pwd module not available; ignoring uid.", 131 level=30) 131 132 val = None 132 133 elif isinstance(val, basestring): … … 140 141 if val is not None: 141 142 if grp is None: 142 self.bus.log("grp module not available; ignoring gid.") 143 self.bus.log("grp module not available; ignoring gid.", 144 level=30) 143 145 val = None 144 146 elif isinstance(val, basestring): … … 154 156 os.umask 155 157 except AttributeError: 156 self.bus.log("umask function not available; ignoring umask.") 158 self.bus.log("umask function not available; ignoring umask.", 159 level=30) 157 160 val = None 158 161 self._umask = val … … 177 180 if self.uid is None and self.gid is None: 178 181 if pwd or grp: 179 self.bus.log('uid/gid not set' )182 self.bus.log('uid/gid not set', level=30) 180 183 else: 181 184 self.bus.log('Started as uid: %r gid: %r' % current_ids()) … … 192 195 else: 193 196 if self.umask is None: 194 self.bus.log('umask not set' )197 self.bus.log('umask not set', level=30) 195 198 else: 196 199 old_umask = os.umask(self.umask) … … 239 242 self.bus.log('There are %r active threads. ' 240 243 'Daemonizing now may cause strange failures.' % 241 threading.enumerate() )244 threading.enumerate(), level=30) 242 245 243 246 # See http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16 trunk/cherrypy/process/servers.py
r1930 r1938 86 86 self.interrupt = sys.exc_info()[1] 87 87 self.bus.log("Error in HTTP server: shutting down", 88 traceback=True )88 traceback=True, level=40) 89 89 self.bus.exit() 90 90 raise trunk/cherrypy/process/win32.py
r1926 r1938 26 26 if result == 0: 27 27 self.bus.log('Could not SetConsoleCtrlHandler (error %r)' % 28 win32api.GetLastError() )28 win32api.GetLastError(), level=40) 29 29 else: 30 30 self.is_set = True … … 42 42 if result == 0: 43 43 self.bus.log('Could not remove SetConsoleCtrlHandler (error %r)' % 44 win32api.GetLastError() )44 win32api.GetLastError(), level=40) 45 45 else: 46 46 self.is_set = False trunk/cherrypy/process/wspbus.py
r1916 r1938 155 155 except: 156 156 self.log("Error in %r listener %r" % (channel, listener), 157 traceback=True)157 level=40, traceback=True) 158 158 exc = sys.exc_info()[1] 159 159 if exc: … … 184 184 raise 185 185 except: 186 self.log("Shutting down due to error in start listener: \n%s" %187 _traceback.format_exc())186 self.log("Shutting down due to error in start listener:", 187 level=40, traceback=True) 188 188 e_info = sys.exc_info() 189 189 try: … … 305 305 return t 306 306 307 def log(self, msg="", traceback=False):307 def log(self, msg="", level=20, traceback=False): 308 308 """Log the given message. Append the last traceback if requested.""" 309 309 if traceback: 310 310 exc = sys.exc_info() 311 311 msg += "\n" + "".join(_traceback.format_exception(*exc)) 312 self.publish('log', msg )312 self.publish('log', msg, level) 313 313 314 314 bus = Bus()

