[PR #13] [MERGED] fix: logging updates to prevent silent errors #48

Closed
opened 2026-10-18 21:13:46 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/terminals/pull/13
Author: @james-westbrook
Created: 3/29/2026
Status: ✅ Merged
Merged: 3/29/2026
Merged by: @tjbck

Base: main ← Head: logging-fixes


📝 Commits (1)

  • 0cb5a73 fix: logging updates to prevent silent errors

📊 Changes

4 files changed (+10 additions, -5 deletions)

View changed files

📝 Dockerfile (+2 -0)
📝 terminals/logging.py (+3 -1)
📝 terminals/main.py (+4 -3)
📝 terminals/migrations/env.py (+1 -1)

📄 Description

Description

Fixes logging silenced after Alembic migrationes

All log messages after startup (including "Idle reaper started", "Application startup complete", and request access logs) were silently dropped in containerized deployments. The idle reaper worked, but was invisible in kubectl logs, making it impossible to confirm or debug.

Root cause

Alembic's fileConfig() call in migrations/env.py reconfigures Python's root logger during init_db(), which:

  1. Replaces our _InterceptHandler (loguru bridge) with a plain StreamHandler at level WARN
  2. Sets disabled=True on all pre-existing loggers via disable_existing_loggers=True (the default)

Since setup_logging() ran before init_db(), our entire logging pipeline was silently destroyed mid-startup.

Fix

  • main.py: Move setup_logging() to run after init_db() so the loguru intercept handler is installed after Alembic is done reconfiguring logging.
  • migrations/env.py: Pass disable_existing_loggers=False to fileConfig() so it doesn't disable loggers created during module import.
  • logging.py: Set propagate=False on intercepted named loggers (uvicorn, sqlalchemy) to prevent duplicate log lines from both the named handler and root handler.
  • Dockerfile: Add ENV PYTHONUNBUFFERED=1 so Python doesn't buffer stderr in containers (standard practice, discovered during investigation).

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/terminals/pull/13 **Author:** [@james-westbrook](https://github.com/james-westbrook) **Created:** 3/29/2026 **Status:** ✅ Merged **Merged:** 3/29/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `main` ← **Head:** `logging-fixes` --- ### 📝 Commits (1) - [`0cb5a73`](https://github.com/open-webui/terminals/commit/0cb5a73e61fd569f81d292afd1d13c6d34e4e34d) fix: logging updates to prevent silent errors ### 📊 Changes **4 files changed** (+10 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `Dockerfile` (+2 -0) 📝 `terminals/logging.py` (+3 -1) 📝 `terminals/main.py` (+4 -3) 📝 `terminals/migrations/env.py` (+1 -1) </details> ### 📄 Description ## Description ### Fixes logging silenced after Alembic migrationes All log messages after startup (including "Idle reaper started", "Application startup complete", and request access logs) were silently dropped in containerized deployments. The idle reaper worked, but was invisible in `kubectl logs`, making it impossible to confirm or debug. ### Root cause Alembic's `fileConfig()` call in `migrations/env.py` reconfigures Python's root logger during `init_db()`, which: 1. Replaces our `_InterceptHandler` (loguru bridge) with a plain `StreamHandler` at level WARN 2. Sets `disabled=True` on all pre-existing loggers via `disable_existing_loggers=True` (the default) Since `setup_logging()` ran *before* `init_db()`, our entire logging pipeline was silently destroyed mid-startup. ### Fix - **`main.py`**: Move `setup_logging()` to run *after* `init_db()` so the loguru intercept handler is installed after Alembic is done reconfiguring logging. - **`migrations/env.py`**: Pass `disable_existing_loggers=False` to `fileConfig()` so it doesn't disable loggers created during module import. - **`logging.py`**: Set `propagate=False` on intercepted named loggers (uvicorn, sqlalchemy) to prevent duplicate log lines from both the named handler and root handler. - **`Dockerfile`**: Add `ENV PYTHONUNBUFFERED=1` so Python doesn't buffer stderr in containers (standard practice, discovered during investigation). --- ## Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](./CLA.md), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-18 21:13:46 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/terminals#48
No description provided.