def logging_config(): lcd = LCDict(attach_handlers_to_root=True) # root level: WARNING lcd.add_stderr_handler('con-err', formatter='level_msg') # console handler level: NOTSET # Add TWO SMTPHandlers, one for each level ERROR and CRITICAL, # which will email technical staff with logged messages of levels >= ERROR. # We use a filter to make the first handler squelch CRITICAL messages: lcd.add_callable_filter("filter-error-only", filter_error_only) # TEST_TO_ADDRESS included just for testing/trying out the example basic_toaddrs = [TEST_TO_ADDRESS, '*****@*****.**'] # add error-only SMTP handler add_smtp_handler_to_lcd(lcd, 'email-error', level='ERROR', toaddrs=basic_toaddrs, subject='ERROR (Alert from SMTPHandler)', filters=['filter-error-only']) # add critical-only SMTP handler add_smtp_handler_to_lcd(lcd, 'email-critical', level='CRITICAL', toaddrs=basic_toaddrs + ['*****@*****.**'], subject='CRITICAL (Alert from SMTPHandler)') lcd.config()
def config_logging(): lcd = LCDict(attach_handlers_to_root=True, root_level='DEBUG') lcd.add_stdout_handler('console-out', level='DEBUG', formatter='level_msg') lcd.add_callable_filter( 'count_info', filter_fn, # extra, static data filtername='count_info', loglevel_to_count=logging.INFO) lcd.attach_root_filters('count_info') lcd.config()