Skip to content

[feat] CLI-02: comprehensive output — session transcript + JSON logs#14

Merged
vt128 merged 1 commit into
masterfrom
feat/cli-output-record
Jun 21, 2026
Merged

[feat] CLI-02: comprehensive output — session transcript + JSON logs#14
vt128 merged 1 commit into
masterfrom
feat/cli-output-record

Conversation

@vt128

@vt128 vt128 commented Jun 21, 2026

Copy link
Copy Markdown
Member

Comprehensive output: --record transcript + --log-format

Rounds out the output story per the maintainer's request to treat output
holistically. The pieces now compose cleanly:

flag captures
-o/--output the display printer (existing)
--record <file> the complete session — print, results, REPL, errors
--log-file <file> + --log-format console|json the structured log module

--record <file> — session transcript (for 复盘/replay)

Tees all of stdout+stderr to a transcript file while still showing it live,
so a whole run (or REPL session) is saved for later review.

  • Implemented in cli/record.go: swap os.Stdout/os.Stderr for pipes and copy
    through a locked writer to both the original stream and the file.
  • stdin is left untouched, so an interactive REPL keeps its terminal.
  • Appended with a timestamped session header; the file is closed on stop
    (deferred in Process), so no descriptor lingers.
$ ./starcli --record session.log job.star      # REPL mode too

--log-format console|json

Selects the zap encoder for --log-file: console (human, default) or json
(machine-ingestible, structured fields included). Unknown format errors.

$ ./starcli --log-file run.log --log-format json job.star
{"level":"info","ts":"","msg":"starting up","n":7}

Tests cover the transcript (live tee + captured, incl. errors), JSON log
lines/fields, and the bad-format error. README documents both. Coverage
76.5% (≥ 65); Docker golang:1.22 green.

…mat json (STAR-19)

Round out the output story per maintainer request.

--record <file>: tee the COMPLETE session output (stdout AND stderr — print,
results, REPL interaction, errors) to a transcript file for later replay/review.
Implemented in cli/record.go by swapping os.Stdout/os.Stderr for pipes and
copying through a locked writer to both the original stream and the file, so
output is still shown live. stdin is left untouched, so an interactive REPL
keeps its terminal. The file is appended with a timestamped session header; it
is closed on stop (deferred in Process), so no descriptor lingers.

--log-format console|json: select the zap encoder for --log-file. console is the
human-readable default; json emits machine-ingestible lines (structured log
fields included). An unknown format errors.

Tests cover the transcript (output tee'd live + captured, incl. errors), JSON
log lines + fields, and the bad-format error. README documents both. Coverage
76.5%; Docker golang:1.22 green.
@vt128 vt128 merged commit 384a98c into master Jun 21, 2026
6 checks passed
@vt128 vt128 deleted the feat/cli-output-record branch June 21, 2026 09:48
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