Skip to content

feat(devserver): Tee console output to a local dev log file#117486

Merged
trevor-e merged 1 commit into
masterfrom
feat/tee-devserver-console-logs-to-dev-file
Jun 12, 2026
Merged

feat(devserver): Tee console output to a local dev log file#117486
trevor-e merged 1 commit into
masterfrom
feat/tee-devserver-console-logs-to-dev-file

Conversation

@trevor-e

Copy link
Copy Markdown
Member

Summary

The devserver now mirrors all honcho-routed console output to a log file (truncated each run) so it can be inspected after the fact — for example, by AI agents reading the local dev logs.

  • A new TeeStream in sentry/runner/formatting.py wraps stdout: it writes to the console verbatim and writes an ANSI-stripped copy to the log file, flushing each write.
  • The interactive console keeps its coloring — TeeStream.isatty() delegates to the underlying console so honcho still colorizes terminal output; only the file copy is stripped.
  • get_honcho_printer(...) gains an optional output parameter; the devserver passes it a TeeStream.
  • The log path defaults to <repo>/.artifacts/dev.log and is configurable via the SENTRY_DEV_LOG_FILE environment variable. Both .artifacts/ and *.log are already gitignored.

This mirrors an approach already in use in the seer repo.

Notes

  • This captures output that flows through honcho (all daemons: server, workers, webpack, consumers). Output emitted before honcho takes over and the bare no-daemon server.run() path are not tee'd, which is fine for the intended use case.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 11, 2026
@trevor-e trevor-e force-pushed the feat/tee-devserver-console-logs-to-dev-file branch 3 times, most recently from aa447e2 to ebea711 Compare June 11, 2026 23:30
The devserver now mirrors all honcho-routed console output to a log file
(truncated each run) so it can be inspected after the fact — for example by
AI agents reading the dev logs. ANSI color codes are stripped from the file
copy while the interactive console keeps its coloring (the tee delegates
isatty()).

The path defaults to <repo>/.artifacts/dev.log and is configurable via the
SENTRY_DEV_LOG_FILE environment variable. Both .artifacts/ and *.log are
already gitignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@trevor-e trevor-e force-pushed the feat/tee-devserver-console-logs-to-dev-file branch from ebea711 to 88bc69c Compare June 11, 2026 23:30
@trevor-e trevor-e marked this pull request as ready for review June 11, 2026 23:49
@trevor-e trevor-e requested a review from a team as a code owner June 11, 2026 23:49

@joshuarli joshuarli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@trevor-e trevor-e merged commit 0bef251 into master Jun 12, 2026
66 checks passed
@trevor-e trevor-e deleted the feat/tee-devserver-console-logs-to-dev-file branch June 12, 2026 14:00
trevor-e pushed a commit that referenced this pull request Jun 15, 2026
Fixes getsentry/self-hosted#4379 
Granian's watchfiles-based reloader watches the entire repo directory by
default. The TeeStream introduced in #117486 writes all
honcho output to .artifacts/dev.log inside the repo root, which
triggered an infinite reload cycle: server logs →-> dev.log updated ->
watchfiles detects change -> granian reloads -> repeat.

Fix by passing reload_ignore_dirs=[".artifacts"] to Granian so
watchfiles skips that directory. The option is surfaced through the
existing options dict so it can be overridden via SENTRY_WEB_OPTIONS if
needed.

<!-- Describe your PR here. -->

<!--

  Sentry employees and contractors can delete or ignore the following.

-->

### Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants