Skip to content
Snippets Groups Projects
  • W. Trevor King's avatar
    0a23831b
    irkerd: Convert to Python's logging module · 0a23831b
    W. Trevor King authored
    Instead of using the local IRCClient.debug() method, use the more
    flexible standard library logger.  This makes it easy to log to
    syslog, rotating files, etc, using the usual logging Handlers.  The
    mapping from the old implementation to the new implementation is:
    
      IRCClient.debug(1, message)  -> LOG.info(message)
      IRCClient.debug(2, message)  -> LOG.debug(message)
      IRCClient.debug(50, message) -> LOG.debug(message)
      Irker.logerr(errmsg)         -> LOG.error(message)
    
    with the exception of the failed-message error, which is logged as
    LOG.warning().  I didn't try and recategorize the other message log
    levels, although I think a number of info-level log messages should
    really be debug-level log messages.
    
    To set the log level, the -d option now takes string arguments
    (e.g. 'info', 'debug') instead of numeric arguments (e.g. '1', '2').
    This breaks backward compatibility, but I think it makes the argument
    more user-friendly.  If you try and set an invalid level, there's a
    helpful error message to guide you in the right direction.
    
    I also use format_exc() in Connection.dequeue (following the existing
    example deeper in the Connection.dequeue nest).  The log level should
    decide whether the traceback is printed or not, not whether the
    exception should be raised or ignored.
    0a23831b
    History
    irkerd: Convert to Python's logging module
    W. Trevor King authored
    Instead of using the local IRCClient.debug() method, use the more
    flexible standard library logger.  This makes it easy to log to
    syslog, rotating files, etc, using the usual logging Handlers.  The
    mapping from the old implementation to the new implementation is:
    
      IRCClient.debug(1, message)  -> LOG.info(message)
      IRCClient.debug(2, message)  -> LOG.debug(message)
      IRCClient.debug(50, message) -> LOG.debug(message)
      Irker.logerr(errmsg)         -> LOG.error(message)
    
    with the exception of the failed-message error, which is logged as
    LOG.warning().  I didn't try and recategorize the other message log
    levels, although I think a number of info-level log messages should
    really be debug-level log messages.
    
    To set the log level, the -d option now takes string arguments
    (e.g. 'info', 'debug') instead of numeric arguments (e.g. '1', '2').
    This breaks backward compatibility, but I think it makes the argument
    more user-friendly.  If you try and set an invalid level, there's a
    helpful error message to guide you in the right direction.
    
    I also use format_exc() in Connection.dequeue (following the existing
    example deeper in the Connection.dequeue nest).  The log level should
    decide whether the traceback is printed or not, not whether the
    exception should be raised or ignored.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.