Fix: route AdkLogger warn and error records to stderr - #672
Open
AmaadMartin wants to merge 2 commits into
Open
Conversation
added 2 commits
August 5, 2026 02:52
The dev Console transport was built with no stderrLevels option, so winston routed every record, including error, to stdout. A supervisor that reads stderr saw nothing when adk web, api_server, run or deploy failed. Configure the transport with the lowercase levels warn and error. Winston matches these against the raw level name on info[LEVEL], not the uppercased display level. Adds dev/test/utils/logger_test.ts, the first direct test for this logger.
Inline the two-element level list at the transport call site, where the lowercase caveat reads better than a detached doc comment. Replace the hand-rolled ANSI stripper with stripVTControlCharacters from node:util, which also removes the dynamic regex built to dodge no-control-regex.
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
N/A
Problem:
AdkLoggerbuilds its winston Console transport with nostderrLevelsoption, so winston writes every record to stdout, includingerror. A CI harness, a process manager ordocker logsreads stderr to learn why a process failed, and gets an empty stream. This affectsadk web,adk api_server,adk run,adk deploy,AdkApiServerandAgentLoader.Solution: Pass
stderrLevels: ['warn', 'error']to the transport. The level names stay lowercase because winston matches them against the raw level name oninfo[LEVEL], not against the uppercased display level that the format chain produces. Message content, layout, colours and thelogLevelthreshold are unchanged; only the file descriptor changes.dev/src/cli/cli.tsis out of scope. Its twoprocess.exit(1)flush sites are already handled by open PR #591, and #595 also edits that file.Collision check: I listed all 571 open PRs on the fork and read the file list of every adjacent one. #432 refactors
dev/src/utils/logger.tsand addsdev/test/utils/logger_test.ts, but keeps a barenew winston.transports.Console(), so the bug survives it.git log --all -S'stderrLevels'returns nothing. I branched frommainrather than stacking on #432, because #432 is a large refactor that is not a prerequisite; if it lands first, the same option moves to wherever the transport ends up.Testing Plan
Unit Tests:
New file
dev/test/utils/logger_test.ts(8 cases). Winston writes toconsole._stdout/console._stderrrather than callingconsole.log, so the test installs its ownnode:consoleConsoleover two capture streams and reads the bytes back.The one failure in
unit:deviscli_create_test.ts > should handle Vertex AI selection with gcloud defaults. It reads the local gcloud config and fails the same way on a clean tree with my commit stashed.Proof the tests can fail. I ran the suite against three mutations of
dev/src/utils/logger.ts:new winston.transports.Console()expected '' to contain 'boom'['WARN', 'ERROR']expected '' to contain 'boom'['debug', 'info', 'warn', 'error']expected '' to contain 'hello'Coverage.
dev/src/utils/logger.tshad no direct test before and now measures 90.66% lines / 94.11% branches. The line I added is covered. Two gaps remain and I left them deliberately:log()(lines 85-90) passes a numeric level to winston, which is a separate defect. A test would pin the bug rather than the fix.error()needslogLevel > LogLevel.ERROR.ERRORis the highest enum member, so no valid input reaches it.Manual End-to-End (E2E) Tests:
Before: the first command printed nothing and the second printed
[ADK CLI] Error starting API server: Port 8811 is already in use. After: they are the other way round.The start-up banner still goes to stdout, which the integration harness greps for:
Checklist