Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1938

Show
Ignore:
Timestamp:
04/05/08 15:04:56
Author:
fumanchu
Message:

Audit of logging:

  1. cherrypy.log now defaults to INFO.
  2. Bus.log now takes a 'level=INFO' arg.
  3. 'log' channel subscribers now must accept a 'level' arg.
  4. Some bus plugin messages upgraded to WARN or ERROR.
  5. Some CP core messages upgraded to ERROR.
  6. log.screen move to stderr polished. See #747.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/__init__.py

    r1926 r1938  
    401401log.access_file = '' 
    402402 
    403 def _buslog(msg): 
    404     log.error(msg, 'ENGINE'
     403def _buslog(msg, level): 
     404    log.error(msg, 'ENGINE', severity=level
    405405engine.subscribe('log', _buslog) 
    406406 
  • trunk/cherrypy/_cplogging.py

    r1873 r1938  
    4343                    h.release() 
    4444     
    45     def error(self, msg='', context='', severity=logging.DEBUG, traceback=False): 
     45    def error(self, msg='', context='', severity=logging.INFO, traceback=False): 
    4646        """Write to the error log. 
    4747         
     
    104104            if not h: 
    105105                if stream is None: 
    106                     stream=sys.stdout 
     106                    stream=sys.stderr 
    107107                h = logging.StreamHandler(stream) 
    108108                h.setLevel(logging.DEBUG) 
     
    122122        self._set_screen_handler(self.access_log, newvalue) 
    123123    screen = property(_get_screen, _set_screen, 
    124                       doc="If True, error and access will print to stdout.") 
     124                      doc="If True, error and access will print to stderr.") 
    125125     
    126126     
  • trunk/cherrypy/_cprequest.py

    r1900 r1938  
    104104                except: 
    105105                    exc = sys.exc_info()[1] 
    106                     cherrypy.log(traceback=True
     106                    cherrypy.log(traceback=True, severity=40
    107107        if exc: 
    108108            raise 
     
    531531                # Failure in setup, error handler or finalize. Bypass them. 
    532532                # Can't use handle_error because we may not have hooks yet. 
    533                 cherrypy.log(traceback=True
     533                cherrypy.log(traceback=True, severity=40
    534534                if self.show_tracebacks: 
    535535                    body = format_exc() 
  • trunk/cherrypy/_cptree.py

    r1930 r1938  
    123123            req.close() 
    124124        except: 
    125             cherrypy.log(traceback=True
     125            cherrypy.log(traceback=True, severity=40
    126126         
    127127        cherrypy.serving.clear() 
  • trunk/cherrypy/_cpwsgi.py

    r1933 r1938  
    9595             
    9696            tb = _cperror.format_exc() 
    97             _cherrypy.log(tb
     97            _cherrypy.log(tb, severity=40
    9898            if not getattr(self.request, "show_tracebacks", True): 
    9999                tb = "" 
     
    115115                raise 
    116116             
    117             _cherrypy.log(traceback=True
     117            _cherrypy.log(traceback=True, severity=40
    118118            self.close() 
    119119             
     
    194194                raise 
    195195             
    196             _cherrypy.log(traceback=True
     196            _cherrypy.log(traceback=True, severity=40
    197197             
    198198            # CherryPy test suite expects bare_error body to be output, 
  • trunk/cherrypy/lib/cptools.py

    r1923 r1938  
    290290def log_traceback(severity=logging.DEBUG): 
    291291    """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) 
    294293 
    295294def log_request_headers(): 
  • trunk/cherrypy/process/plugins.py

    r1926 r1938  
    128128        if val is not None: 
    129129            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) 
    131132                val = None 
    132133            elif isinstance(val, basestring): 
     
    140141        if val is not None: 
    141142            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) 
    143145                val = None 
    144146            elif isinstance(val, basestring): 
     
    154156                os.umask 
    155157            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) 
    157160                val = None 
    158161        self._umask = val 
     
    177180            if self.uid is None and self.gid is None: 
    178181                if pwd or grp: 
    179                     self.bus.log('uid/gid not set'
     182                    self.bus.log('uid/gid not set', level=30
    180183            else: 
    181184                self.bus.log('Started as uid: %r gid: %r' % current_ids()) 
     
    192195        else: 
    193196            if self.umask is None: 
    194                 self.bus.log('umask not set'
     197                self.bus.log('umask not set', level=30
    195198            else: 
    196199                old_umask = os.umask(self.umask) 
     
    239242            self.bus.log('There are %r active threads. ' 
    240243                         'Daemonizing now may cause strange failures.' % 
    241                          threading.enumerate()
     244                         threading.enumerate(), level=30
    242245         
    243246        # See http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16 
  • trunk/cherrypy/process/servers.py

    r1930 r1938  
    8686            self.interrupt = sys.exc_info()[1] 
    8787            self.bus.log("Error in HTTP server: shutting down", 
    88                          traceback=True
     88                         traceback=True, level=40
    8989            self.bus.exit() 
    9090            raise 
  • trunk/cherrypy/process/win32.py

    r1926 r1938  
    2626        if result == 0: 
    2727            self.bus.log('Could not SetConsoleCtrlHandler (error %r)' % 
    28                          win32api.GetLastError()
     28                         win32api.GetLastError(), level=40
    2929        else: 
    3030            self.is_set = True 
     
    4242        if result == 0: 
    4343            self.bus.log('Could not remove SetConsoleCtrlHandler (error %r)' % 
    44                          win32api.GetLastError()
     44                         win32api.GetLastError(), level=40
    4545        else: 
    4646            self.is_set = False 
  • trunk/cherrypy/process/wspbus.py

    r1916 r1938  
    155155            except: 
    156156                self.log("Error in %r listener %r" % (channel, listener), 
    157                          traceback=True) 
     157                         level=40, traceback=True) 
    158158                exc = sys.exc_info()[1] 
    159159        if exc: 
     
    184184            raise 
    185185        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
    188188            e_info = sys.exc_info() 
    189189            try: 
     
    305305        return t 
    306306     
    307     def log(self, msg="", traceback=False): 
     307    def log(self, msg="", level=20, traceback=False): 
    308308        """Log the given message. Append the last traceback if requested.""" 
    309309        if traceback: 
    310310            exc = sys.exc_info() 
    311311            msg += "\n" + "".join(_traceback.format_exception(*exc)) 
    312         self.publish('log', msg
     312        self.publish('log', msg, level
    313313 
    314314bus = Bus() 

Hosted by WebFaction

Log in as guest/cpguest to create tickets