| Conditions | 2 |
| Total Lines | 21 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | |||
| 9 | def initiate_logger(self, logger_file_name): |
||
| 10 | # initiate Logging |
||
| 11 | self.logger = logging.getLogger('thm') |
||
| 12 | # set logging level to desired level only if specified |
||
| 13 | if logger_file_name == 'None': |
||
| 14 | self.logger.setLevel(logging.NOTSET) |
||
| 15 | else: |
||
| 16 | self.logger.setLevel(logging.DEBUG) |
||
| 17 | # defining log file and setting rotating logic |
||
| 18 | log_handler = handlers.TimedRotatingFileHandler(logger_file_name, |
||
| 19 | when = 'h', |
||
| 20 | interval = 1, |
||
| 21 | backupCount = 5, |
||
| 22 | encoding = 'utf-8', |
||
| 23 | utc = False) |
||
| 24 | # Here we define our formatter |
||
| 25 | log_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') |
||
| 26 | # Here we set our logHandler's formatter |
||
| 27 | log_handler.setFormatter(log_formatter) |
||
| 28 | # pairing the handler with logging |
||
| 29 | self.logger.addHandler(log_handler) |
||
| 30 |