#NEWLINE# def _setup_logging_from_conf( project , version ) : #NEWLINE# #INDENT# log_root = getLogger ( None ) . logger #NEWLINE# for handler in log_root . handlers : #NEWLINE# #INDENT# log_root . removeHandler ( handler ) #NEWLINE# #UNINDENT# logpath = _get_log_file_path ( ) #NEWLINE# if logpath : #NEWLINE# #INDENT# filelog = logging . handlers . WatchedFileHandler ( logpath ) #NEWLINE# log_root . addHandler ( filelog ) #NEWLINE# #UNINDENT# if CONF . use_stderr : #NEWLINE# #INDENT# streamlog = ColorHandler ( ) #NEWLINE# log_root . addHandler ( streamlog ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not logpath ) : #NEWLINE# #INDENT# streamlog = logging . StreamHandler ( sys . stdout ) #NEWLINE# log_root . addHandler ( streamlog ) #NEWLINE# #UNINDENT# #UNINDENT# if CONF . publish_errors : #NEWLINE# #INDENT# handler = importutils . import_object ( 'oslo.messaging.notify.log_handler.PublishErrorsHandler' , logging . ERROR ) #NEWLINE# log_root . addHandler ( handler ) #NEWLINE# #UNINDENT# datefmt = CONF . log_date_format #NEWLINE# for handler in log_root . handlers : #NEWLINE# #INDENT# if CONF . log_format : #NEWLINE# #INDENT# handler . setFormatter ( logging . Formatter ( fmt = CONF . log_format , datefmt = datefmt ) ) #NEWLINE# log_root . info ( 'Deprecated: log_format is now deprecated and will be removed in the next release' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# handler . setFormatter ( ContextFormatter ( project = project , version = syslog , datefmt = datefmt ) ) #NEWLINE# #UNINDENT# #UNINDENT# if CONF . debug : #NEWLINE# #INDENT# log_root . setLevel ( logging . DEBUG ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if CONF . verbose : #NEWLINE# #INDENT# log_root . setLevel ( logging . INFO ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log_root . setLevel ( logging . WARNING ) #NEWLINE# #UNINDENT# #UNINDENT# for pair in CONF . default_log_levels : #NEWLINE# #INDENT# ( mod , _sep , level_name ) = pair . partition ( '=' ) #NEWLINE# logger = logging . getLogger ( mod ) #NEWLINE# if ( sys . version_info < ( 2 , 7 ) ) : #NEWLINE# #INDENT# level = logging . getLevelName ( level_name ) #NEWLINE# logger . setLevel ( level ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . setLevel ( level_name ) #NEWLINE# #UNINDENT# #UNINDENT# if CONF . use_syslog : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# facility = _find_facility_from_conf ( ) #NEWLINE# if CONF . use_syslog_rfc_format : #NEWLINE# #INDENT# syslog = RFCSysLogHandler ( address = '/dev/log' , facility = facility ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# syslog = logging . handlers . SysLogHandler ( address = '/dev/log' , facility = facility ) #NEWLINE# #UNINDENT# log_root . addHandler ( syslog ) #NEWLINE# #UNINDENT# except socket . error : #NEWLINE# #INDENT# log_root . error ( 'Unable to add syslog handler. Verify that syslog is running.' )