Revert "chore: improve validation and handler of logging timezone with TimezoneName" (#10077)

This commit is contained in:
crazywoola
2024-10-30 22:06:10 +08:00
committed by GitHub
parent a69513c044
commit 0a3d51e9cf
2 changed files with 12 additions and 10 deletions

View File

@@ -1,10 +1,8 @@
import logging
import os
import sys
from datetime import datetime
from logging.handlers import RotatingFileHandler
import pytz
from flask import Flask
from configs import dify_config
@@ -32,10 +30,16 @@ def init_app(app: Flask):
handlers=log_handlers,
force=True,
)
log_tz = dify_config.LOG_TZ
if log_tz:
from datetime import datetime
import pytz
timezone = pytz.timezone(log_tz)
def time_converter(seconds):
return datetime.utcfromtimestamp(seconds).astimezone(timezone).timetuple()
for handler in logging.root.handlers:
handler.formatter.converter = lambda seconds: (
datetime.fromtimestamp(seconds, tz=pytz.UTC).astimezone(log_tz).timetuple()
)
handler.formatter.converter = time_converter