feat(logs): daily rotation + timestamps for raw stream log#42
Open
janstol wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The LaunchAgent launcher previously redirected all stdout/stderr into a single, ever-growing
~/logs/mcptask_runner/<slug>.logwith no timestamps.lib/mcptask_runner/log_filter.rb, a stdlib-only stdin→file filter piped from the generated launcher script.[Claude],[EventStream]) so multi-line pretty-printed JSON bodies stay readable — indented lines (including nested JSON arrays like[) are left untouched.~/logs/mcptask_runner/<slug>/YYYY-MM-DD.log.ruby(notbundle 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 pipefailkeeps the launcher's exit status reflecting the rake task rather than the filter.Migration
Existing installs need
bundle exec rake mcptask_runner:install FORCE=1to pick this up. Old flat<slug>.logfiles are left in place, harmless.Test plan
ruby bin/ci— all green (tests, RuboCop, Reek, Flay)test/services/log_filter_test.rbcoversdecorate(entry lines, JSON bodies, blank lines, indented nested arrays),dated_path, and end-to-end rotation across a day boundarytest/services/installer_test.rbfor the new launcher script shape (pipe instead ofexec >>) and log filter installation[Claude]/[EventStream]lines through the filter and confirmed correct timestamping + file placement