feat: Handle '/dev/stdout' in Logger Configuration

This commit is contained in:
gmailnovo 2023-12-07 11:27:45 +08:00 committed by GitHub
parent 86fbd62048
commit f1350a2940
1 changed files with 7 additions and 6 deletions

View File

@ -192,10 +192,11 @@ def configure_logger(app):
app.logger.addHandler(handler) app.logger.addHandler(handler)
log_file = app.config['LOG_PATH'] log_file = app.config['LOG_PATH']
file_handler = RotatingFileHandler(log_file, if log_file and log_file != "/dev/stdout":
maxBytes=2 ** 30, file_handler = RotatingFileHandler(log_file,
backupCount=7) maxBytes=2 ** 30,
file_handler.setLevel(getattr(logging, app.config['LOG_LEVEL'])) backupCount=7)
file_handler.setFormatter(formatter) file_handler.setLevel(getattr(logging, app.config['LOG_LEVEL']))
app.logger.addHandler(file_handler) file_handler.setFormatter(formatter)
app.logger.addHandler(file_handler)
app.logger.setLevel(getattr(logging, app.config['LOG_LEVEL'])) app.logger.setLevel(getattr(logging, app.config['LOG_LEVEL']))