#NEWLINE# def get_logger( name , settings , console = False , log_file_name = None ) : #NEWLINE# #INDENT# '\n    Defaults to set up logging to a file.\n    If console==True also add a StreamHandler to log to console\n    ' #NEWLINE# if ( formatter is None ) : #NEWLINE# #INDENT# log_file_name = ( ( settings . LOG_DIR + name ) + '.log' ) #NEWLINE# #UNINDENT# ( os . path . isdir ( settings . LOG_DIR ) or os . makedirs ( settings . LOG_DIR ) ) #NEWLINE# log = logging . getLogger ( name ) #NEWLINE# log . setLevel ( settings . LOG_LEVEL ) #NEWLINE# handler = RotatingFileHandler ( log_file_name ) #NEWLINE# formatter = logging . Formatter ( settings . LOG_FORMAT ) #NEWLINE# handler . setFormatter ( formatter ) #NEWLINE# log . addHandler ( handler ) #NEWLINE# if console : #NEWLINE# #INDENT# foreground_handler = StreamHandler ( sys . stdout ) #NEWLINE# log . addHandler ( foreground_handler ) #NEWLINE# #UNINDENT# return log