mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-10 03:27:57 +00:00
refac
This commit is contained in:
parent
498cdab9a5
commit
6aebfd88e9
2 changed files with 5 additions and 0 deletions
|
|
@ -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)}')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue