#NEWLINE# def _setup_file_log( self ) : #NEWLINE# #INDENT# 'Add a file log handler.' #NEWLINE# namespace = self . _meta . namespace #NEWLINE# file_path = self . app . config . get ( self . _meta . config_section , 'file' ) #NEWLINE# rotate = self . app . config . get ( self . _meta . config_section , 'rotate' ) #NEWLINE# max_bytes = self . app . config . get ( self . _meta . config_section , 'max_bytes' ) #NEWLINE# max_files = self . app . config . get ( self . _meta . config_section , 'max_files' ) #NEWLINE# if file_path : #NEWLINE# #INDENT# file_path = fs . abspath ( file_path ) #NEWLINE# log_dir = os . path . dirname ( file_path ) #NEWLINE# if ( not os . path . exists ( log_dir ) ) : #NEWLINE# #INDENT# os . makedirs ( log_dir ) #NEWLINE# #UNINDENT# if rotate : #NEWLINE# #INDENT# from logging.handlers import RotatingFileHandler #NEWLINE# file_handler = RotatingFileHandler ( file_path , maxBytes = int ( max_bytes ) , backupCount = int ( max_files ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# from logging import FileHandler #NEWLINE# file_handler = FileHandler ( file_path ) #NEWLINE# #UNINDENT# format = self . _get_file_format ( ) #NEWLINE# formatter = self . _get_file_formatter ( format ) #NEWLINE# file_handler . setFormatter ( formatter ) #NEWLINE# file_handler . setLevel ( getattr ( logging , self . get_level ( ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# file_handler = NullHandler ( ) #NEWLINE# #UNINDENT# for i in logging . getLogger ( ( 'cement:app:%s' % namespace ) ) . handlers : #NEWLINE# #INDENT# if isinstance ( i , file_handler . __class__ ) : #NEWLINE# #INDENT# self . backend . removeHandler ( i ) #NEWLINE# #UNINDENT# #UNINDENT# self . backend . addHandler ( file_handler )