8000 feat(logs): structured logs, a log viewer and sending to syslog by adeelahmad · Pull Request #284 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(logs): structured logs, a log viewer and sending to syslog - #284

Merged
adeelahmad merged 7 commits into
mainfrom
claude/project-thread-phs458
Oct 14, 2026
Merged

adeelahmad merged 7 commits into
mainfrom
claude/project-thread-phs458

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: the API logged plain text at a fixed INFO level, workers printed to stdout, and the only way to read logs was docker logs. Nothing could go to a log server.

After: every process (API, lens worker, lens watch) writes structured, redacted records. Settings → Logs sets the level (plus per-logger levels like httpx warning), console format (text or JSON), and log files, shows the latest lines from every process with search and filters, and can send lines to a syslog server (RFC 5424 over UDP, TCP or TLS) with a "Send a test line" button. Sending off-box is off by default. LENS_LOG_LEVEL and LENS_LOG_FORMAT in .env win over Settings.

How: app/domain/logs.py adds handlers to the root logger: the console, a rotating JSON-lines file per process under data_dir/logs (read back by GET /admin/logs), and a syslog handler that queues lines and sends them from a background thread, so a slow or down server never blocks a request; when the queue is full lines are dropped and counted. Bearer/basic credentials, key=/token=/password= pairs, URL passwords and common key shapes are replaced with *** before anything is written. Settings are re-applied whenever they're saved, so changes take effect without a restart. Uvicorn's access and error logs go through the same outputs. New endpoints: GET /admin/logs, GET /settings/logs/status, POST /settings/logs/test.

Motivation and Context

Adeel asked for logging, and for sending logs to a remote syslog server. Lens already had a syslog sensor, which receives logs; this adds sending them out.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Not built yet: sending directly to Loki or other HTTP endpoints, and TLS client certificates.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ENYWvvG9ffuX4mAJN61ACV


Generated by Claude Code

Every process (API, workers, watcher) writes structured, redacted log
records to the console (text or JSON), to a rotating JSON-lines file per
process under data_dir/logs, and, when turned on, to a syslog server
(RFC 5424 over UDP, TCP or TLS) from a background queue. Settings → Logs
sets the level, per-logger levels, files and syslog, shows the latest
lines from every process, and sends a test line. Off-box sending is off
by default; LENS_LOG_LEVEL and LENS_LOG_FORMAT win over Settings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENYWvvG9ffuX4mAJN61ACV
@adeelahmad adeelahmad self-assigned this Oct 10, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENYWvvG9ffuX4mAJN61ACV
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENYWvvG9ffuX4mAJN61ACV
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENYWvvG9ffuX4mAJN61ACV
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENYWvvG9ffuX4mAJN61ACV
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ENYWvvG9ffuX4mAJN61ACV
@adeelahmad
adeelahmad merged commit 4131e68 into main Oct 14, 2026
10 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-phs458 branch October 14, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0