yzk_wechat_event/utils/logger.py

12 lines
416 B
Python
Raw Permalink Normal View History

2023-12-13 11:41:22 +08:00
import logging
class CustomFileHandler(logging.FileHandler):
def _get_or_create_filename(self, suffix):
# Override the method to include the date in the filename
if self.stream is None:
# Reopen the file with a new filename that includes the date
filename = self.baseFilename + suffix
self.stream = self._open(filename, 'a')
return self.baseFilename