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
评论列表
文章目录