[feat] CLI-02/C-4: --log-file routes the script log module to a file#13
Merged
Conversation
…(STAR-19) Add --log-file <path>: when a script uses the starlet log module, its output is captured to that file at the interpreter level, so a host can collect a run's logs in one place. - starbox routes the log module through the box logger (module.go: it uses slog.NewModule(userLog) when a logger is set), so BuildBox builds a file-backed zap logger (console encoder, ISO8601 time, all levels) and SetLogger's it when --log-file is given. - The parent directory is created if needed; runs append. The logger is memoized per path so the web mode (a BuildBox per request) shares one open file instead of leaking a descriptor each request. Tests route a script's log.info to a temp --log-file (nested dir) and assert the message + level land in the file. README documents it. Coverage 75.9%; Docker golang:1.22 green.
…them The fileLogger memo holds the log file open for the process lifetime; on Windows an open file cannot be deleted, so TestProcess_LogFile's t.TempDir cleanup failed there. Track the *os.File handles and add closeLogFiles(); the test registers it via t.Cleanup (after TempDir, so LIFO runs it first) to release the handle before RemoveAll.
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.
CLI-02 / C-4 —
--log-filecaptures the script'slogoutputWhen a script uses the
logmodule,--log-file <path>captures its output tothat file at the interpreter level, so a host can collect a run's logs in
one place.
How
starbox routes the
logmodule through the box logger (module.gousesslog.NewModule(userLog)when one is set), soBuildBoxbuilds a file-backedzap logger (console encoder, ISO8601 time, all levels) and
SetLoggers it when--log-fileis given.BuildBoxper request)shares one open file instead of leaking a descriptor each request.
Tests route a script's
log.infoto a temp--log-file(nested dir) and assertthe message + level land in the file. README documents it. Coverage 75.9%
(≥ 65); Docker
golang:1.22green.Completes the CLI-02 set (STAR-19): check (#9) · args (#11) · stdin (#12) · log-file.