Skip to content

feat(logs): daily rotation + timestamps for raw stream log#42

Open
janstol wants to merge 1 commit into
mainfrom
feat/log-rotation
Open

feat(logs): daily rotation + timestamps for raw stream log#42
janstol wants to merge 1 commit into
mainfrom
feat/log-rotation

Conversation

@janstol

@janstol janstol commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

The LaunchAgent launcher previously redirected all stdout/stderr into a single, ever-growing ~/logs/mcptask_runner/<slug>.log with no timestamps.

  • Adds lib/mcptask_runner/log_filter.rb, a stdlib-only stdin→file filter piped from the generated launcher script.
  • Timestamps only entry-start lines (e.g. [Claude], [EventStream]) so multi-line pretty-printed JSON bodies stay readable — indented lines (including nested JSON arrays like [) are left untouched.
  • Rotates into a daily file per project: ~/logs/mcptask_runner/<slug>/YYYY-MM-DD.log.
  • Filter is invoked with plain ruby (not bundle exec) from a stable helper-bin path copied in by the installer, so logging survives even while the launcher is healing a broken/stale bundle.
  • set -o pipefail keeps the launcher's exit status reflecting the rake task rather than the filter.

Migration

Existing installs need bundle exec rake mcptask_runner:install FORCE=1 to pick this up. Old flat <slug>.log files are left in place, harmless.

Test plan

  • ruby bin/ci — all green (tests, RuboCop, Reek, Flay)
  • New test/services/log_filter_test.rb covers decorate (entry lines, JSON bodies, blank lines, indented nested arrays), dated_path, and end-to-end rotation across a day boundary
  • Updated test/services/installer_test.rb for the new launcher script shape (pipe instead of exec >>) and log filter installation
  • Manual: piped sample [Claude]/[EventStream] lines through the filter and confirmed correct timestamping + file placement

The LaunchAgent launcher previously redirected all stdout/stderr into a single,
ever-growing ~/logs/mcptask_runner/<slug>.log with no timestamps.

Add lib/mcptask_runner/log_filter.rb, a stdlib-only stdin->file filter piped
from the generated launcher script. It timestamps only entry-start lines
(e.g. "[Claude]", "[EventStream]") so multi-line pretty-printed JSON bodies
stay readable, and rotates into a daily file per project:
~/logs/mcptask_runner/<slug>/YYYY-MM-DD.log.

The filter is invoked with plain `ruby` (not `bundle exec`) from a stable
helper-bin path copied in by the installer, so logging survives even while
the launcher is healing a broken/stale bundle. `set -o pipefail` keeps the
launcher's exit status reflecting the rake task rather than the filter.

Existing installs need `bundle exec rake mcptask_runner:install FORCE=1` to
pick this up; old flat <slug>.log files are left in place, harmless.
@janstol
janstol requested review from Pepan and mracek-bit July 15, 2026 16:39
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.

1 participant