refac
This commit is contained in:
1 parent
498cdab9a5
commit
6aebfd88e9
2 files changed
+5
No files matched your search
@@ -102,6 +102,7 @@ class JSONFormatter(logging.Formatter):
|
|||||||
|
|
||||||
|
|
||||||
LOG_FORMAT = os.getenv('LOG_FORMAT', '').lower()
|
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()
|
GLOBAL_LOG_LEVEL = os.getenv('GLOBAL_LOG_LEVEL', '').upper()
|
||||||
if GLOBAL_LOG_LEVEL in logging.getLevelNamesMapping():
|
if GLOBAL_LOG_LEVEL in logging.getLevelNamesMapping():
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from open_webui.env import (
|
|||||||
ENABLE_OTEL_LOGS,
|
ENABLE_OTEL_LOGS,
|
||||||
GLOBAL_LOG_LEVEL,
|
GLOBAL_LOG_LEVEL,
|
||||||
LOG_FORMAT,
|
LOG_FORMAT,
|
||||||
|
LOGURU_DIAGNOSE,
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@@ -178,6 +179,7 @@ def start_logger():
|
|||||||
_json_sink,
|
_json_sink,
|
||||||
level=GLOBAL_LOG_LEVEL,
|
level=GLOBAL_LOG_LEVEL,
|
||||||
filter=audit_filter,
|
filter=audit_filter,
|
||||||
|
diagnose=LOGURU_DIAGNOSE,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.add(
|
logger.add(
|
||||||
@@ -185,6 +187,7 @@ def start_logger():
|
|||||||
level=GLOBAL_LOG_LEVEL,
|
level=GLOBAL_LOG_LEVEL,
|
||||||
format=stdout_format,
|
format=stdout_format,
|
||||||
filter=audit_filter,
|
filter=audit_filter,
|
||||||
|
diagnose=LOGURU_DIAGNOSE,
|
||||||
)
|
)
|
||||||
if AUDIT_LOG_LEVEL != 'NONE' and ENABLE_AUDIT_LOGS_FILE:
|
if AUDIT_LOG_LEVEL != 'NONE' and ENABLE_AUDIT_LOGS_FILE:
|
||||||
try:
|
try:
|
||||||
@@ -195,6 +198,7 @@ def start_logger():
|
|||||||
compression='zip',
|
compression='zip',
|
||||||
format=file_format,
|
format=file_format,
|
||||||
filter=lambda record: record['extra'].get('auditable') is True,
|
filter=lambda record: record['extra'].get('auditable') is True,
|
||||||
|
diagnose=LOGURU_DIAGNOSE,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f'Failed to initialize audit log file handler: {str(e)}')
|
logger.error(f'Failed to initialize audit log file handler: {str(e)}')
|
||||||
|
|||||||
Reference in new issue
Block a user