FEATURE: Togglable server-side (Docker) log streaming debug endpoint #45

Closed
opened 2026-05-24 11:08:07 +01:00 by Gandalf · 3 comments
Owner

Title:
FEATURE: Togglable server-side (Docker) log streaming debug endpoint with dual-authentication

Problem / Requirement:
Administrators and developers need a lightweight, real-time method to stream application stdout/stderr logs (which correspond exactly to Docker container logs in standard setups) directly through the API. This enables easier live debugging without requiring full Docker daemon or terminal access.

Success Criteria:

  1. Lightweight Log Streaming: Streams process standard output/error (representing Docker logs) via Server-Sent Events (SSE). Keep a rolling buffer of the last 1000 lines in memory.
  2. Dual-Authentication with Webhook Secret Bypass:
    • Accepts existing session cookie (emby_user) with administrative credentials.
    • Accepts standard HTTP Basic Authentication (Authorization: Basic ) using Emby administrator username/password credentials.
    • Accepts X-Webhook-Secret header matching the SOFARR_WEBHOOK_SECRET environment variable for programmatic bypass.
  3. Runtime Configuration Toggle: Enableable using a runtime environment variable ENABLE_LOG_STREAM=true (defaulting to false/disabled). When disabled, returns a 403 Forbidden response.
  4. API Spec Documentation: Documented in server/openapi.yaml under the /api/debug/logs endpoint, including the query format and response schemas.
Title: FEATURE: Togglable server-side (Docker) log streaming debug endpoint with dual-authentication Problem / Requirement: Administrators and developers need a lightweight, real-time method to stream application stdout/stderr logs (which correspond exactly to Docker container logs in standard setups) directly through the API. This enables easier live debugging without requiring full Docker daemon or terminal access. Success Criteria: 1. Lightweight Log Streaming: Streams process standard output/error (representing Docker logs) via Server-Sent Events (SSE). Keep a rolling buffer of the last 1000 lines in memory. 2. Dual-Authentication with Webhook Secret Bypass: - Accepts existing session cookie (emby_user) with administrative credentials. - Accepts standard HTTP Basic Authentication (Authorization: Basic <base64>) using Emby administrator username/password credentials. - Accepts X-Webhook-Secret header matching the SOFARR_WEBHOOK_SECRET environment variable for programmatic bypass. 3. Runtime Configuration Toggle: Enableable using a runtime environment variable ENABLE_LOG_STREAM=true (defaulting to false/disabled). When disabled, returns a 403 Forbidden response. 4. API Spec Documentation: Documented in server/openapi.yaml under the /api/debug/logs endpoint, including the query format and response schemas.
Gandalf added the Kind/Feature
Priority
Medium
3
labels 2026-05-24 11:08:07 +01:00
Author
Owner

Amended the plan to include a high-priority bypass using the X-Webhook-Secret request header:

  1. Webhook Secret Bypass: If the request contains the X-Webhook-Secret header, we verify if it matches the configured SOFARR_WEBHOOK_SECRET environment variable.
  2. Access Granted: If matching, the request is immediately authorized, completely bypassing session and Emby Basic Auth checks. This is ideal for curl scripts, server-to-server monitoring, or external debugging logs captures.

I have updated the implementation_plan.md artifact to reflect this amendment.

Amended the plan to include a high-priority bypass using the `X-Webhook-Secret` request header: 1. **Webhook Secret Bypass**: If the request contains the `X-Webhook-Secret` header, we verify if it matches the configured `SOFARR_WEBHOOK_SECRET` environment variable. 2. **Access Granted**: If matching, the request is immediately authorized, completely bypassing session and Emby Basic Auth checks. This is ideal for curl scripts, server-to-server monitoring, or external debugging logs captures. I have updated the `implementation_plan.md` artifact to reflect this amendment.
Author
Owner

Amended the plan to add client-side console log capturing and streaming options:

Proposed Client Logging Design:

  • Client-Side Capture (Frontend Interception): Hook into standard browser console methods (console.log, console.warn, console.error) at client-side startup.
  • Client-to-Server Transmission:
    • Option A (Recommended): Store captured logs in a local memory queue, and periodically perform a batched POST /api/debug/client-logs (every 2 seconds or when the queue hits 20 items) to minimize network overhead.
    • Option B (WebSocket Channel): Stream logs instantly via persistent WebSockets, which adds structural and connection management complexity.
  • Server Storage & SSE Streaming:
    • Store incoming client logs in a separate rolling 1000-line buffer clientLogBuffer.
    • Expose GET /api/debug/client-logs/stream (under the exact same dual-auth/webhook-secret constraints) to stream client-side logs in real-time via SSE to debugging tools.

The implementation_plan.md artifact has been successfully updated with these options.

Amended the plan to add client-side console log capturing and streaming options: ### Proposed Client Logging Design: - **Client-Side Capture (Frontend Interception)**: Hook into standard browser console methods (`console.log`, `console.warn`, `console.error`) at client-side startup. - **Client-to-Server Transmission**: - **Option A (Recommended)**: Store captured logs in a local memory queue, and periodically perform a batched `POST /api/debug/client-logs` (every 2 seconds or when the queue hits 20 items) to minimize network overhead. - **Option B (WebSocket Channel)**: Stream logs instantly via persistent WebSockets, which adds structural and connection management complexity. - **Server Storage & SSE Streaming**: - Store incoming client logs in a separate rolling 1000-line buffer `clientLogBuffer`. - Expose `GET /api/debug/client-logs/stream` (under the exact same dual-auth/webhook-secret constraints) to stream client-side logs in real-time via SSE to debugging tools. The `implementation_plan.md` artifact has been successfully updated with these options.
Gandalf changed title from FEATURE: Log streaming debug endpoint with dual-authentication and runtime configuration to FEATURE: Togglable server-side (Docker) log streaming debug endpoint 2026-05-24 11:21:12 +01:00
Author
Owner

Resolved in commit 3c6791658c.

Resolved in commit 3c6791658c8fb05f15b84cbdba1815eef40823d1.
Gandalf added the Area/Frontend label 2026-05-28 11:58:06 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/sofarr#45