Fix: apply the resolved log level in every command that advertises it - #929
Open
AmaadMartin wants to merge 1 commit into
Open
Conversation
The deploy commands never resolved --verbose / --log_level at all, so the ADK core logger stayed at its default. The CLI's own AdkLogger was never level-adjusted on any command. applyLogLevel() resolves the level once and applies it to both loggers the CLI owns. All seven commands that advertise the options call it.
AmaadMartin
force-pushed
the
fix/cli-apply-log-level-in-all-commands
branch
from
August 11, 2026 11:51
155ee53 to
80744f1
Compare
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:
adk deploy cloud_run,deploy agent_engineanddeploy reasoning_engineadvertise-v/--verboseand--log_level, but their actions never resolve either flag. The ADK core logger therefore keeps its default level on every deploy. Separately, the CLI's ownAdkLoggeris never level-adjusted on any command, so it stays atINFOwhatever the user asks for.Solution:
applyLogLevel()resolves the level once and applies it to both loggers the CLI owns: the ADK core logger and the CLI's ownAdkLogger. All seven commands that advertise the options now call it, including the two deploy actions that had no call at all.cli.tsonly emitslogger.errortoday, so no message it prints changes yet; the level is now honest for any record the CLI logs.Stacked on #700. The collision check found #592 and #700 already on this file. #592 fixes the
||that discardedLogLevel.DEBUG; #700 makes--verbosea--log_level debugshortcut and wiresintegration conformance. Neither touches the CLI's own logger or the deploy actions, so this branch stacks on #700 instead of competing with it.--verboseprecedence is inherited from #700 and not changed here.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.
npx vitest run --project unit:dev dev/test/cli/cli_test.ts— 111 passed. A newlog level wiringblock spies onAdkLogger.prototype.setLogLeveland asserts both loggers for all seven command surfaces, at--verbose,--log_level errorand the no-flag default.One test covers the error path. It makes
deployToCloudRunreject, runsdeploy cloud_run --log_level error, and asserts the message still reaches the console. This pins the invariant that the strictest selectable level does not swallow deploy failures.Proof each new test can fail. I ran each mutation against the new tests:
logger.setLogLevel(logLevel)fromapplyLogLevelexpected "setLogLevel" to be called with arguments: [ +0 ]applyLogLevel(logger, options)from thecloud_runactiondeploy cloud_runcasesapplyLogLevel(logger, options)from theagent_engineactionagent_engineandreasoning_enginecasesAdkLogger.error's gate tothis.logLevel >= LogLevel.ERRORexpected '' to contain 'Error deploying agent: permission denied'Coverage.
dev/src/cli/cli.tsmoves from 97.13% lines / 77.27% branches to 97.59% / 80.43%. Every line this change adds is covered. The remaining gap is five pre-existingcatchblocks this change does not touch.Unrelated failures.
dev/test/cli/cli_create_test.tsfails one case, andnpm run ts:checkreports 313 errors in 53 files. Both are identical on the stack base with my commit stashed, so neither comes from this change.Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.
Build with
npm install && npm run build, then create an agent directory inside the checkout so@google/adkresolves.node dev/dist/esm/cli_entrypoint.js deploy agent_engine <agent> --project <p> --region us-central1 --temp_folder <tmp>— the deploy runs the newapplyLogLevelcall and still fails with the expectedArtifact Registry repository is not specifiedmessage.--log_level error— the error message still prints, which is the invariant the unit test pins.node dev/dist/esm/cli_entrypoint.js integration conformance --verbose --agents_dir <dir> --tests_dir <dir>— the run completes and reports its agents and tests.CI is
absenton this PR: the base isfix/cli-verbose-log-level-precedence, and the test workflow triggers onpull_requestintomain. I validated the pushed commit locally instead: the targeted vitest run above,npx eslint dev/src/cli/cli.ts dev/test/cli/cli_test.ts(clean), andnpx prettier --checkon both files (clean).A complexity review asked me to inline
getLogLevelFromOptions, which this change had reduced to a single caller.applyLogLevelnow holds that one expression and its comment. The??is still pinned: changing it back to||fails 25 tests, includingapplies --log_level debugfrom #592.Checklist
[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.