def __init__(self, fileName=__DEF__.CONFIG_FILE): # Initialize parser object self._parser = ConfigParser() try: # Read .ini file self._file = __DEF__.join(__DEF__.ROOT_DATA, fileName) self._parser.read(self._file) except: critical("Exception on file %s", self._file, exc_info=True)
def start_logging(fileName=__DEF__.LOGGING_FILE): """Initialize logging object and setup console/file handler""" # Get root logger _logger = __LOG__.getLogger() # Create formatter _formatter = __LOG__.Formatter(fmt=__DEF__.LOGGING_FORMAT, datefmt="%Y-%m-%d %H:%M:%S") # Create console handler and set name/level/format _consolehandler = __LOG__.StreamHandler() _consolehandler.set_name("console_handler") _consolehandler.setLevel(__DEF__.LOGGING_LEVEL_CONSOLE) _consolehandler.setFormatter(_formatter) # Create file handler and set name/level/format _file = __DEF__.join(__DEF__.ROOT_DATA, fileName) _filehandler = __LOG__.FileHandler(_file, mode='w') _filehandler.set_name("file_handler") _filehandler.setLevel(__DEF__.LOGGING_LEVEL_FILE) _filehandler.setFormatter(_formatter) # Add console and file handlers to logger _logger.addHandler(_consolehandler) _logger.addHandler(_filehandler) # Return Output return True