refactor: send all logging to stderr through an injectable Logger - #66
Merged
Conversation
JiriLojda
approved these changes
Aug 13, 2026
…g ones to standard
JiriLojda
approved these changes
Aug 14, 2026
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.
Motivation
logInfowrote toconsole.log— stdout. Harmless while every command prints prose, but themapicommand this branch builds on writes a response body to stdout. At that point every progress line lands inside the payload:kontent mapi content-types > types.jsonputs log lines in the JSON,| jqdies on the first one. Fixing the boundary beforemapiemits a payload means it lands correct instead of being retrofitted.What changed
logInfo/logWarning/logError/isVerboseare replaced by aLoggerclosure. Handlers build it once withcreateLoggerFromArgs(args)and pass it down; core takes aLoggerparameter or carries it indeps, so it no longer seesLogOptionsand can be tested by injecting asinkinstead of stubbingconsole.chalkStderr.chalkderives its level from stdout, so a piped stdout would otherwise strip colour from a stderr that is still a terminal.src/lib/ui/prompts.tsbinds@clack/promptsto stderr in one place rather than at every call site. Side effect: spinners keep animating when stdout is piped, because clack's TTY check reads the stream it is handed.--logLevelis typed end to end.LogLevelderives from thechoicestuple, so yargs infers the union;LogOptionsstays the flat parser shape and is collapsed into a single level bycreateLoggerFromArgs.No user-facing change —
--logLevel,--ll,--verboseandKONTENT_LOG_LEVELbehave exactly as before.Checklist
Loggerconvention)How to test