refac
This commit is contained in:
@@ -790,6 +790,11 @@ if OFFLINE_MODE:
|
|||||||
####################################
|
####################################
|
||||||
# AUDIT LOGGING
|
# AUDIT LOGGING
|
||||||
####################################
|
####################################
|
||||||
|
|
||||||
|
|
||||||
|
ENABLE_AUDIT_STDOUT = os.getenv("ENABLE_AUDIT_STDOUT", "False").lower() == "true"
|
||||||
|
ENABLE_AUDIT_LOGS_FILE = os.getenv("ENABLE_AUDIT_LOGS_FILE", "True").lower() == "true"
|
||||||
|
|
||||||
# Where to store log file
|
# Where to store log file
|
||||||
# Defaults to the DATA_DIR/audit.log. To set AUDIT_LOGS_FILE_PATH you need to
|
# Defaults to the DATA_DIR/audit.log. To set AUDIT_LOGS_FILE_PATH you need to
|
||||||
# provide the whole path, like: /app/audit.log
|
# provide the whole path, like: /app/audit.log
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ from typing import TYPE_CHECKING
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from opentelemetry import trace
|
from opentelemetry import trace
|
||||||
from open_webui.env import (
|
from open_webui.env import (
|
||||||
AUDIT_UVICORN_LOGGER_NAMES,
|
ENABLE_AUDIT_STDOUT,
|
||||||
|
ENABLE_AUDIT_LOGS_FILE,
|
||||||
|
AUDIT_LOGS_FILE_PATH,
|
||||||
AUDIT_LOG_FILE_ROTATION_SIZE,
|
AUDIT_LOG_FILE_ROTATION_SIZE,
|
||||||
AUDIT_LOG_LEVEL,
|
AUDIT_LOG_LEVEL,
|
||||||
AUDIT_LOGS_FILE_PATH,
|
|
||||||
GLOBAL_LOG_LEVEL,
|
GLOBAL_LOG_LEVEL,
|
||||||
|
AUDIT_UVICORN_LOGGER_NAMES,
|
||||||
ENABLE_OTEL,
|
ENABLE_OTEL,
|
||||||
ENABLE_OTEL_LOGS,
|
ENABLE_OTEL_LOGS,
|
||||||
)
|
)
|
||||||
@@ -130,9 +132,11 @@ def start_logger():
|
|||||||
sys.stdout,
|
sys.stdout,
|
||||||
level=GLOBAL_LOG_LEVEL,
|
level=GLOBAL_LOG_LEVEL,
|
||||||
format=stdout_format,
|
format=stdout_format,
|
||||||
filter=lambda record: "auditable" not in record["extra"],
|
filter=lambda record: (
|
||||||
|
"auditable" not in record["extra"] if ENABLE_AUDIT_STDOUT else True
|
||||||
|
),
|
||||||
)
|
)
|
||||||
if AUDIT_LOG_LEVEL != "NONE":
|
if AUDIT_LOG_LEVEL != "NONE" and ENABLE_AUDIT_LOGS_FILE:
|
||||||
try:
|
try:
|
||||||
logger.add(
|
logger.add(
|
||||||
AUDIT_LOGS_FILE_PATH,
|
AUDIT_LOGS_FILE_PATH,
|
||||||
|
|||||||
Reference in New Issue
Block a user