def __init__(self, app: WSGIHandler, crawler_settings: Settings) -> None:
_cplogging.LogManager.__init__(
self, id(self), cherrypy.log.logger_root)
self.app = app
max_bytes = getattr(self, "rot_maxBytes", 10000000)
backup_count = getattr(self, "rot_backupCount", 1000)
# Make a new RotatingFileHandler for the error log.
file_name = getattr(self, "rot_error_file", "error.log")
h = RotatingFileHandler(file_name, 'a', max_bytes, backup_count)
h.setLevel(logging.DEBUG)
h.setFormatter(_cplogging.logfmt)
self.error_log.addHandler(h)
if crawler_settings.webserver.write_access_log:
# Make a new RotatingFileHandler for the access log.
file_name = getattr(self, "rot_access_file", "access.log")
h = RotatingFileHandler(file_name, 'a', max_bytes, backup_count)
h.setLevel(logging.DEBUG)
h.setFormatter(_cplogging.logfmt)
self.access_log.addHandler(h)
if crawler_settings.mail_logging.enable:
s = SMTPHandler( # type: ignore
crawler_settings.mail_logging.mailhost,
crawler_settings.mail_logging.from_,
crawler_settings.mail_logging.to,
subject=crawler_settings.mail_logging.subject,
credentials=crawler_settings.mail_logging.credentials
)
s.setLevel(logging.CRITICAL)
self.error_log.addHandler(s)
评论列表
文章目录