config.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:pywhdfs 作者: yassineazzouz 项目源码 文件源码
def get_log_handler(self):
      """Configure and return file logging handler."""
      path = osp.join(gettempdir(), 'pywebhdfs.log')
      level = lg.DEBUG

      if 'configuration' in self.config:
        configuration = self.config['configuration']
        if 'logging' in configuration:
          logging_config = configuration['logging']
          if 'disable' in logging_config and logging_config['disable'] == True:
            return NullHandler()
          if 'path' in logging_config:
            path = logging_config['path'] # Override default path.
          if 'level' in logging_config:
            level = getattr(lg, logging_config['level'].upper())

      log_handler = TimedRotatingFileHandler(
          path,
          when='midnight', # Daily backups.
          backupCount=5,
          encoding='utf-8',
      )
      fmt = '%(asctime)s\t%(name)-16s\t%(levelname)-5s\t%(message)s'
      log_handler.setFormatter(lg.Formatter(fmt))
      log_handler.setLevel(level)
      return log_handler
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号