def config_logging(use_locking): if not sys.platform.startswith('darwin'): raise NotImplementedError( "This example is currently implemented only for OS X / macOS") print("%s locking" % ("Using" if use_locking else "NOT using")) lcd = LCDict(root_level='DEBUG', attach_handlers_to_root=True, locking=use_locking) # Set up console handler to show process name, time, handler name lcd.add_stderr_handler( 'console', level='WARNING', formatter='process_level_msg' ) # Add syslog handler with same formatter lcd.add_syslog_handler( 'h_syslog', formatter='process_level_msg', address='/var/run/syslog', # works for OS X; '/dev/log' for *nix ) lcd.check() lcd.config()
def config_logging(): """Add a stdout console handler with level=WARNING to the root logger, and a syslog handler with default level=NOTSET. Root logger level will be DEBUG. """ # Defaults: # attach_handlers_to_root=False, lcd = LCDict(attach_handlers_to_root=True, locking=True, root_level='DEBUG') lcd.add_stdout_handler('console', level='WARNING', formatter='msg') if not sys.platform.startswith('darwin'): raise NotImplementedError( "This example is currently implemented only for OS X / macOS") # add a syslog handler lcd.add_syslog_handler( 'h_syslog', formatter='logger_level_msg', address='/var/run/syslog', ) lcd.config()