Skip to content

feat: per-job log sink for ProgressDisplay#54

Merged
Sootopolis merged 1 commit into
mainfrom
wip
May 18, 2026
Merged

feat: per-job log sink for ProgressDisplay#54
Sootopolis merged 1 commit into
mainfrom
wip

Conversation

@Sootopolis

Copy link
Copy Markdown
Owner

Summary

  • Introduces JobLogSink (trait + StdoutSink default + currentSink: FiberRef[JobLogSink]) in ccas.utils. ProgressDisplay.asZLogger resolves the active sink from the ZLogger callback's context map so the lookup stays sync while inheriting across forked children.
  • Adds FileSink in ccas.server.jobs — per-job, appends ANSI-stripped lines to ${job-logs.directory}/<jobId>.log, tees raw to stdout. JobRunner.submit wraps each runJob in JobLogSink.currentSink.locally(FileSink(...)) so success/failure handlers' logs also land in the file.
  • JobLogTransport trait stub added; FileTail impl deferred to File-tail logs endpoint GET /api/jobs/{id}/logs #47.
  • HOCON: job-logs.directory = "logs/jobs" (prod, env override JOB_LOGS_DIR) and target/test-job-logs (test). Directory created once at JobRunner.live startup.

Closes #42. Unblocks #47.

Test plan

  • sbt compile clean (only intentional : Unit annotation, no warnings).
  • New TestJobLogSink (5 tests): default sink identity, file-append, ANSI-strip, stdout-tee, currentSink.locally routing through ProgressDisplay.live.
  • New testSubmitWritesJobLog in TestJobRunner: end-to-end job → log file contains the message, no ESC bytes.
  • TestProgressBar regression — all 13 existing assertions pass (default StdoutSink preserves current behaviour byte-for-byte).
  • Full sbt test — 736 pass.

Follow-ups

🤖 Generated with Claude Code

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>
@Sootopolis Sootopolis merged commit d73de65 into main May 18, 2026
1 check passed
@Sootopolis Sootopolis deleted the wip branch May 18, 2026 13:35
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.

Refactor ProgressDisplay to accept a configurable log sink (JobLogTransport)

1 participant