Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat: add log date timezone (#4623)

liuzhenghua9d5a89eab613
diff --git a/api/app.py b/api/app.py
index 6227c73ea3f..52461aac930 100644
--- a/api/app.py
+++ b/api/app.py
@@ -110,9 +110,21 @@ def create_app() -> Flask:
level=app.config.get('LOG_LEVEL'),
format=app.config.get('LOG_FORMAT'),
datefmt=app.config.get('LOG_DATEFORMAT'),
- handlers=log_handlers
+ handlers=log_handlers,
+ force=True
)
+ log_tz = app.config.get('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 = time_converter
initialize_extensions(app)
register_blueprints(app)
register_commands(app)
diff --git a/api/configs/feature/__init__.py b/api/configs/feature/__init__.py
index f880ab6f502..e820761b06d 100644
--- a/api/configs/feature/__init__.py
+++ b/api/configs/feature/__init__.py
@@ -165,6 +165,11 @@ class LoggingConfigs(BaseModel):
default=None,
)
+ LOG_TZ: Optional[str] = Field(
+ description='specify log timezone, eg: America/New_York',
+ default=None,
+ )
+
class ModelLoadBalanceConfigs(BaseModel):
"""