UTILITIES.py 文件源码

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

项目:ALBATROSS 作者: KVSDURGASURESH 项目源码 文件源码
def _setup_logger(self, loggername, logfile, level=logging.INFO, maxFileBytes=100000):
        """
          Function for logging the entire test run details into a file specified with timestamp
          USAGE:
          _execute('loggername', 'logfile')

          loggername : The name of the logger (ex: Daily_Metrics)
          logfile    : The file name including the directory name

          NOTE:
          This method/function can be used for logging and test event into a specific logger file
          """

        self.loggername = loggername
        self.logfile = logfile
        self.maxFileBytes = maxFileBytes

        logs = logging.getLogger(loggername)
        logs.setLevel(level)
        handler = RotatingFileHandler(logfile, maxBytes=maxFileBytes, backupCount=5)
        fmt = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s", datefmt='%Y-%m-%d %H:%M:%S')
        handler.setFormatter(fmt)
        logs.addHandler(handler)
        assert isinstance(logs, object)
        return logs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号