feat: per-job log sink for ProgressDisplay#54
Merged
Merged
Conversation
Introduces JobLogSink (ccas.utils) — sync writeSync + UIO write
wrapper — with a FiberRef-based per-job override. ProgressDisplay's
ZLogger resolves the active sink from the callback's context map so
the lookup stays sync while inheriting across forked children.
JobRunner.submit wraps each runJob in
`JobLogSink.currentSink.locally(FileSink(...))` so per-job log lines
land in `${job-logs.directory}/<jobId>.log` with ANSI stripped, while
stdout is tee'd for the server console. log directory comes from
HOCON (`job-logs.directory`, env override `JOB_LOGS_DIR`) and is
created once at JobRunner.live startup.
JobLogTransport trait stub added; FileTail impl is deferred to #47.
Closes #42.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
JobLogSink(trait +StdoutSinkdefault +currentSink: FiberRef[JobLogSink]) inccas.utils.ProgressDisplay.asZLoggerresolves the active sink from the ZLogger callback'scontextmap so the lookup stays sync while inheriting across forked children.FileSinkinccas.server.jobs— per-job, appends ANSI-stripped lines to${job-logs.directory}/<jobId>.log, tees raw to stdout.JobRunner.submitwraps eachrunJobinJobLogSink.currentSink.locally(FileSink(...))so success/failure handlers' logs also land in the file.JobLogTransporttrait stub added;FileTailimpl deferred to File-tail logs endpoint GET /api/jobs/{id}/logs #47.job-logs.directory = "logs/jobs"(prod, env overrideJOB_LOGS_DIR) andtarget/test-job-logs(test). Directory created once atJobRunner.livestartup.Closes #42. Unblocks #47.
Test plan
sbt compileclean (only intentional: Unitannotation, no warnings).TestJobLogSink(5 tests): default sink identity, file-append, ANSI-strip, stdout-tee,currentSink.locallyrouting throughProgressDisplay.live.testSubmitWritesJobLoginTestJobRunner: end-to-end job → log file contains the message, no ESC bytes.TestProgressBarregression — all 13 existing assertions pass (defaultStdoutSinkpreserves current behaviour byte-for-byte).sbt test— 736 pass.Follow-ups
FileSinkbehaviour under sustained write failures (stderr-spam latch trade-off).BufferedWriteropen; move file IO out ofProgressDisplay's lock (bundle with File-tail logs endpoint GET /api/jobs/{id}/logs #47 lifecycle work).🤖 Generated with Claude Code