[feat] CLI-02: comprehensive output — session transcript + JSON logs#14
Merged
Conversation
…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.
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.
Comprehensive output:
--recordtranscript +--log-formatRounds out the output story per the maintainer's request to treat output
holistically. The pieces now compose cleanly:
-o/--output--record <file>--log-file <file>+--log-format console|jsonlogmodule--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.
cli/record.go: swapos.Stdout/os.Stderrfor pipes and copythrough a locked writer to both the original stream and the file.
(deferred in
Process), so no descriptor lingers.$ ./starcli --record session.log job.star # REPL mode too--log-format console|jsonSelects the zap encoder for
--log-file:console(human, default) orjson(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.22green.