MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / initFileLogger

Method initFileLogger

src/Config.py:561–581  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

559 logging.getLogger('').addHandler(console_logger)
560
561 def initFileLogger(self):
562 if self.action == "main":
563 log_file_path = "%s/debug.log" % self.log_dir
564 else:
565 log_file_path = "%s/cmd.log" % self.log_dir
566
567 if self.log_rotate == "off":
568 file_logger = logging.FileHandler(log_file_path, "w", "utf-8")
569 else:
570 when_names = {"weekly": "w", "daily": "d", "hourly": "h"}
571 file_logger = logging.handlers.TimedRotatingFileHandler(
572 log_file_path, when=when_names[self.log_rotate], interval=1, backupCount=self.log_rotate_backup_count,
573 encoding="utf8"
574 )
575
576 if os.path.isfile(log_file_path):
577 file_logger.doRollover() # Always start with empty log file
578 file_logger.setFormatter(logging.Formatter('[%(asctime)s] %(levelname)-8s %(name)s %(message)s'))
579 file_logger.setLevel(logging.getLevelName(self.log_level))
580 logging.getLogger('').setLevel(logging.getLevelName(self.log_level))
581 logging.getLogger('').addHandler(file_logger)
582
583 def initLogging(self, console_logging=None, file_logging=None):
584 if console_logging == None:

Callers 1

initLoggingMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected