feat(log): add CONFLUENT_VERBOSITY and TTY color - #3469
Draft
Dave Shoup (shouples) wants to merge 3 commits into
Draft
feat(log): add CONFLUENT_VERBOSITY and TTY color#3469Dave Shoup (shouples) wants to merge 3 commits into
CONFLUENT_VERBOSITY and TTY color#3469Dave Shoup (shouples) wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
|
CONFLUENT_VERBOSITY and TTY color
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.



Release Notes
New Features
CONFLUENT_VERBOSITYenvironment variable to set log verbosity without repeating-v(same0-4scale as the-vcount flag; a-vflag on the command line always wins).Checklist
Whatsection below whether this PR applies to Confluent Cloud, Confluent Platform, or both.Test & Reviewsection below.Blast Radiussection below.Applies to both Cloud and Platform (shared logging). Feature-flag items are N/A - this ships on by default, not behind a flag.
What
Two logging quality-of-life changes, both in
pkg/log.CONFLUENT_VERBOSITYlets you set log verbosity from the environment instead of passing-vevery time - handy for a debugging session or CI. It uses the same0-4scale as the-vcount flag and only applies when no-vis passed, since-vis a count flag where0cannot be distinguished from "not set". A value that is not a non-negative integer is ignored with a one-line[WARN]to stderr, because someone who set the variable meant to raise verbosity and would otherwise get silence with no hint why. (The advice caps at4, not5: level5isUNSAFE_TRACE, which is credential-bearing and stays gated behind the separate--unsafe-traceflag.)TTY color: log output is colorized only when the writer is an actual terminal, decided explicitly via
isattyrather thanhclog'sAutoColor- which left color on for any file-descriptor-less writer and seeded ANSI escape codes into buffers (for example, test output).Applies to: both Confluent Cloud and Confluent Platform.
Blast Radius
Small and diagnostic-only. Both changes affect log presentation, not command behavior, output formats, or exit codes. Worst case for the env var is unexpected log verbosity in a session where
CONFLUENT_VERBOSITYwas left set; worst case for color is ANSI codes appearing where they are not wanted (mitigated by the explicit TTY check). No customer command would break.References
fix-log-flush; last of the logging-fix stack.Test & Review
pkg/log/logger_test.gocovers: the env var setting verbosity when no flag is passed, a-vflag overriding it, an unset variable being a silent no-op, and an invalid value being ignored with the warning.CONFLUENT_VERBOSITY=3 confluent ...raises verbosity with no-v;CONFLUENT_VERBOSITY=x confluent ...prints the[WARN]and proceeds at the default level; log output is colored in a terminal and plain when piped to a file.go test ./pkg/log/...passes.Why the env var is not documented in
--verbose's flag helpThat help string renders in every command's global-flags block, so mentioning the env var there would rewrite ~1139 help golden files for a one-line note. The
VerbosityEnvVardoc comment records it in source instead. The nameCONFLUENT_VERBOSITY(numeric, mirroring-v) was chosen over*_LOG_LEVEL, which would imply named levels the code does not parse.