def __init__(self, filepath=None):
        """ Borg pattern """
        self.__dict__ = self.__state
        if '_log' not in self.__dict__:
            config = Config()
            if filepath:
                self.filepath = filepath
            elif 'filepath' in config.logger:
                self.filepath = config.logger['filepath']
            else:
                self.filepath = '/var/log/decanter.log'

            try:
                handler = logging.handlers.TimedRotatingFileHandler(
                    self.filepath, 'midnight', 1, 10, 'UTF-8')
            except IOError:
                # check if log directory exists
                parent_path = parent_path = os.path.abspath(
                    os.path.dirname(self.filepath))
                if not os.path.exists(parent_path):
                    # try to create the logs directory
                    os.makedirs(parent_path, mode=0o755)
                # and try again
                handler = logging.handlers.TimedRotatingFileHandler(
                    self.filepath, 'midnight', 1, 10, 'UTF-8')

            formatter = logging.Formatter('%(levelname)s - %(asctime)s - ' +
                                          'File:%(pathname)s - Line:' +
                                          '%(lineno)d - Func:' +
                                          '%(funcName)s\n%(message)s')

            handler.setLevel(config.logger['level'])
            handler.setFormatter(formatter)
            self._log = logging.getLogger(__name__)
            self._log.setLevel(config.logger['level'])
            self._log.addHandler(handler)
dataset/ETHPy150Open gengo/decanter/decanter/lib/logger.py/Log.__init__/original