open-webui/backend/open_webui/utils
Andrei Efanov 9e81e1dda1
feat: add LOG_FORMAT=json for structured JSON logging (#21747)
* feat: add LOG_FORMAT env var with JSON formatter for early logging

Introduce LOG_FORMAT environment variable (set to "json" to enable).
When active, logging.basicConfig() uses a JSONFormatter that outputs
single-line JSON objects with fields: ts, level, msg, caller, error,
stacktrace. This covers all log messages emitted during module imports
before Loguru's start_logger() takes over.

* feat: add JSON sink for Loguru when LOG_FORMAT=json

Add _json_sink() as a Loguru sink function that writes single-line JSON
to stdout. In start_logger(), conditionally use the JSON sink instead of
the plain-text stdout_format when LOG_FORMAT is set to "json".

* feat: suppress ASCII banner and fix alembic logging in JSON mode

- Wrap the ASCII art banner print in main.py with a LOG_FORMAT != "json"
  guard so JSON output stays machine-parseable.
- Skip alembic's fileConfig() call in migrations/env.py when
  LOG_FORMAT=json to prevent it from replacing the JSON log handlers
  installed during early startup.
2026-02-22 17:40:17 -06:00
..
images refac/fix: comfyui filter output node type 2025-12-30 12:24:48 +04:00
mcp Merge pull request #21485 from Classic298/claude/fix-mcp-ssl-check-0janH 2026-02-19 14:08:15 -06:00
telemetry chore: format 2026-02-11 16:24:11 -06:00
access_control.py chore: format 2026-02-11 16:24:11 -06:00
actions.py refac 2026-02-11 16:40:40 -06:00
anthropic.py refac 2026-02-21 15:35:34 -06:00
audit.py chore: format 2026-02-11 16:24:11 -06:00
auth.py refac 2026-02-19 16:29:19 -06:00
channels.py feat: channel/thread @ model 2025-09-17 00:49:44 -05:00
chat.py refac 2026-02-16 15:32:28 -06:00
code_interpreter.py chore: format 2026-02-11 16:24:11 -06:00
embeddings.py chore: format 2026-02-11 16:24:11 -06:00
files.py refac 2026-01-28 01:18:39 +04:00
filter.py chore/perf: Remove old SRC level log env vars with no impact (#20045) 2025-12-20 08:16:14 -05:00
groups.py refac/enh: db session sharing 2025-12-29 00:21:18 +04:00
headers.py refac 2026-02-06 03:23:37 +04:00
logger.py feat: add LOG_FORMAT=json for structured JSON logging (#21747) 2026-02-22 17:40:17 -06:00
middleware.py perf: eliminate 2 redundant full chat deserialization on every message send (#21596) 2026-02-21 14:53:31 -06:00
misc.py refac 2026-02-21 15:35:34 -06:00
models.py feat: default model metadata & params 2026-02-22 16:54:34 -06:00
oauth.py refac 2026-02-21 15:35:34 -06:00
payload.py refac: ollama str think support 2026-02-22 17:11:50 -06:00
pdf_generator.py chore: remove unnecessary Path conversions 2025-03-04 19:53:52 +02:00
plugin.py refac 2026-02-21 15:35:34 -06:00
rate_limit.py feat: signin rate limit 2025-12-02 03:52:38 -05:00
redis.py REDIS_RECONNECT_DELAY as positive float for handle retry delay on timeout/connection errors (#21021) 2026-01-29 17:13:03 +04:00
response.py refac: "tool_calls" finish reason support 2026-02-16 00:53:01 -06:00
sanitize.py chore: format 2026-02-11 16:24:11 -06:00
security_headers.py chore: format 2024-11-30 23:36:30 -08:00
task.py chore: format 2026-02-11 16:24:11 -06:00
tools.py refac 2026-02-21 15:35:34 -06:00
validate.py chore: format 2026-02-11 16:24:11 -06:00
webhook.py refac 2026-01-08 00:42:29 +04:00