mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-13 01:02:25 -06:00
refac
This commit is contained in:
@@ -102,6 +102,7 @@ class JSONFormatter(logging.Formatter):
|
||||
|
||||
|
||||
LOG_FORMAT = os.getenv('LOG_FORMAT', '').lower()
|
||||
LOGURU_DIAGNOSE = os.getenv('LOGURU_DIAGNOSE', 'False').lower() == 'true'
|
||||
|
||||
GLOBAL_LOG_LEVEL = os.getenv('GLOBAL_LOG_LEVEL', '').upper()
|
||||
if GLOBAL_LOG_LEVEL in logging.getLevelNamesMapping():
|
||||
|
||||
@@ -17,6 +17,7 @@ from open_webui.env import (
|
||||
ENABLE_OTEL_LOGS,
|
||||
GLOBAL_LOG_LEVEL,
|
||||
LOG_FORMAT,
|
||||
LOGURU_DIAGNOSE,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -178,6 +179,7 @@ def start_logger():
|
||||
_json_sink,
|
||||
level=GLOBAL_LOG_LEVEL,
|
||||
filter=audit_filter,
|
||||
diagnose=LOGURU_DIAGNOSE,
|
||||
)
|
||||
else:
|
||||
logger.add(
|
||||
@@ -185,6 +187,7 @@ def start_logger():
|
||||
level=GLOBAL_LOG_LEVEL,
|
||||
format=stdout_format,
|
||||
filter=audit_filter,
|
||||
diagnose=LOGURU_DIAGNOSE,
|
||||
)
|
||||
if AUDIT_LOG_LEVEL != 'NONE' and ENABLE_AUDIT_LOGS_FILE:
|
||||
try:
|
||||
@@ -195,6 +198,7 @@ def start_logger():
|
||||
compression='zip',
|
||||
format=file_format,
|
||||
filter=lambda record: record['extra'].get('auditable') is True,
|
||||
diagnose=LOGURU_DIAGNOSE,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f'Failed to initialize audit log file handler: {str(e)}')
|
||||
|
||||
Reference in New Issue
Block a user