#NEWLINE# @ functions . CallOnce #NEWLINE# def SetupLogger( ) : #NEWLINE# #INDENT# 'Configure logging for OpenHTF.' #NEWLINE# record_logger = logging . getLogger ( RECORD_LOGGER ) #NEWLINE# record_logger . propagate = False #NEWLINE# record_logger . setLevel ( logging . DEBUG ) #NEWLINE# record_logger . addHandler ( logging . StreamHandler ( stream = sys . stdout ) ) #NEWLINE# logger = logging . getLogger ( LOGGER_PREFIX ) #NEWLINE# logger . propagate = False #NEWLINE# logger . setLevel ( logging . DEBUG ) #NEWLINE# formatter = logging . Formatter ( '%(asctime)s - %(levelname)s - %(message)s' ) #NEWLINE# if LOGFILE : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# cur_time = str ( util . TimeMillis ( ) ) #NEWLINE# file_handler = logging . FileHandler ( ( '%s.%s' % ( LOGFILE , cur_time ) ) ) #NEWLINE# file_handler . setFormatter ( formatter ) #NEWLINE# file_handler . setLevel ( DEFAULT_LOGFILE_LEVEL . upper ( ) ) #NEWLINE# file_handler . addFilter ( MAC_FILTER ) #NEWLINE# logger . addHandler ( file_handler ) #NEWLINE# #UNINDENT# except IOError as exception : #NEWLINE# #INDENT# print ( ( 'Failed to set up log file due to error: %s. Continuing anyway.' % exception ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not QUIET ) : #NEWLINE# #INDENT# console_handler = logging . StreamHandler ( stream = sys . stderr ) #NEWLINE# console_handler . setFormatter ( formatter ) #NEWLINE# console_handler . setLevel ( DEFAULT_LEVEL . upper ( ) ) #NEWLINE# console_handler . addFilter ( MAC_FILTER ) #NEWLINE# logger . addHandler ( console_handler )