borg-backup-ui icon indicating copy to clipboard operation
borg-backup-ui copied to clipboard

Reduce routine API log noise before beta

Open borg-codex-bot opened this issue 4 months ago • 1 comments

Context

The application log is currently useful for proving that the server is running, but it is too noisy for support. A sample log from 2026-07-22 had 1,625 lines, including hundreds of routine raw HTTP request lines and structured API ok lines. Many polling endpoints are logged repeatedly while carrying empty context.

This makes it harder for testers and maintainers to spot the important events when diagnosing backup, restore, notification or migration problems.

Goal

Make the default application log quieter and more support-focused before beta, without hiding errors, write operations, security events or slow requests.

Scope

  • Suppress or debug-gate raw BaseHTTPRequestHandler HTTP access lines for routine UI/API traffic.
  • Avoid duplicate logging where both raw HTTP access lines and structured API ok lines describe the same successful request.
  • Stop logging successful routine polling GET requests at INFO level by default, especially:
    • /api/status
    • /api/jobs
    • /api/jobs/running
    • /api/system-health
    • /api/setup-status
    • /api/auth/status
    • static UI asset requests
  • Continue logging all API errors at normal level.
  • Continue logging all write operations at normal level, including POST, PUT, PATCH and DELETE.
  • Continue logging security-relevant events at normal level.
  • Log successful GET requests when they are slow or unusually large, using a documented threshold.
  • Add or document a debug mode that can re-enable verbose access logging for local troubleshooting.

Acceptance criteria

  • Normal dashboard polling no longer floods borg_backup_ui.log.
  • Successful GET requests for frequent polling endpoints are suppressed at INFO level unless slow or otherwise noteworthy.
  • API errors still include request id, method, path, status, error code and sanitized detail.
  • POST/PUT/PATCH/DELETE requests are still visible with request id, method, path, status, duration and relevant context.
  • Security audit lines are unchanged or improved, but not suppressed.
  • Slow successful GETs are logged with duration and response size.
  • No secrets are added to logs.
  • Tests cover the logging decision rules for routine GET, slow GET, write request and API error cases.

Suggested implementation

  • Centralize the API access logging decision in borg_backup_ui.py.
  • Add a small helper such as _should_log_api_success(method, path, duration_ms, status, bytes_out).
  • Override or adjust log_message() so raw HTTP lines are not emitted for normal UI/API traffic unless debug logging is enabled.
  • Keep the structured API log as the canonical request log.

Notes

This is stage 1 of the pre-beta support logging work. Stage 2 should enrich context fields, and stage 3 should add backup/restore lifecycle summaries.

borg-codex-bot avatar Jul 22 '26 10:07 borg-codex-bot

Additional startup-runtime requirement from log review:

The app log can contain an early line like:

FEHLER: python3 nicht gefunden. Bitte Plugin 'Python 3 for Unraid' installieren.\n```\n\nfollowed by a successful line such as:\n\n```text\nPython Runtime: /usr/bin/python3\n```\n\nThis is likely caused by Unraid boot ordering: `/boot/config/go` may call `rc.borg_backup_ui start` before the Python 3 plugin has fully initialized or before `python3` is available in PATH. The service can then start successfully on a later attempt, leaving a stale scary error at the top of the support log.\n\nPre-beta logging cleanup should handle this as follows:\n\n- Make `plugin/rc.borg_backup_ui` use a robust PATH before checking Python.\n- Replace the immediate hard error with a short bounded retry/wait loop, for example 60 seconds total with small sleep intervals.\n- Log an informational waiting line only once, not on every retry.\n- Only log the `FEHLER: python3 nicht gefunden` message if Python is still missing after the retry window.\n- If Python becomes available during the wait, log a resolved line such as `Python Runtime ready after 12s: /usr/bin/python3` instead of leaving a false error.\n- Keep real missing/too-old Python errors clear and actionable.\n\nAcceptance addition:\n\n- A transient Python-unavailable state during Unraid boot does not leave a false error in `borg_backup_ui.log` when the service starts successfully afterwards.\n

borg-codex-bot avatar Jul 22 '26 10:07 borg-codex-bot