Skip to content

feat(log): add CONFLUENT_VERBOSITY and TTY color - #3469

Draft
Dave Shoup (shouples) wants to merge 3 commits into
djs/fix-log-flushfrom
djs/log-verbosity-env
Draft

feat(log): add CONFLUENT_VERBOSITY and TTY color#3469
Dave Shoup (shouples) wants to merge 3 commits into
djs/fix-log-flushfrom
djs/log-verbosity-env

Conversation

@shouples

Copy link
Copy Markdown
Contributor

Release Notes

New Features

  • Added the CONFLUENT_VERBOSITY environment variable to set log verbosity without repeating -v (same 0-4 scale as the -v count flag; a -v flag on the command line always wins).
  • CLI log output is now colorized when it is written to a terminal, and left plain when redirected to a file or pipe.

Checklist

  • I have successfully built and used a custom CLI binary, without linter issues from this PR.
  • I have clearly specified in the What section below whether this PR applies to Confluent Cloud, Confluent Platform, or both.
  • I have verified this PR in Confluent Cloud pre-prod or production environment, if applicable.
  • I have verified this PR in Confluent Platform on-premises environment, if applicable.
  • I have attached manual CLI verification results or screenshots in the Test & Review section below.
  • I have added appropriate CLI integration or unit tests for any new or updated commands and functionality.
  • I confirm that this PR introduces no breaking changes or backward compatibility issues.
  • I have indicated the potential customer impact if something goes wrong in the Blast Radius section below.
  • I have put checkmarks below confirming that the feature associated with this PR is enabled in:
    • Confluent Cloud prod
    • Confluent Cloud stag
    • Confluent Platform
    • Check this box if the feature is enabled for certain organizations only

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_VERBOSITY lets you set log verbosity from the environment instead of passing -v every time - handy for a debugging session or CI. It uses the same 0-4 scale as the -v count flag and only applies when no -v is passed, since -v is a count flag where 0 cannot 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 at 4, not 5: level 5 is UNSAFE_TRACE, which is credential-bearing and stays gated behind the separate --unsafe-trace flag.)

TTY color: log output is colorized only when the writer is an actual terminal, decided explicitly via isatty rather than hclog's AutoColor - 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_VERBOSITY was 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

  • Stacked on fix-log-flush; last of the logging-fix stack.

Test & Review

  • pkg/log/logger_test.go covers: the env var setting verbosity when no flag is passed, a -v flag overriding it, an unset variable being a silent no-op, and an invalid value being ignored with the warning.
  • Manual: 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 help

That 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 VerbosityEnvVar doc comment records it in source instead. The name CONFLUENT_VERBOSITY (numeric, mirroring -v) was chosen over *_LOG_LEVEL, which would imply named levels the code does not parse.

Dave Shoup (shouples) and others added 3 commits August 20, 2026 17:19
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>
@confluent-cla-assistant

Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@sonarqube-confluent

Copy link
Copy Markdown

@shouples Dave Shoup (shouples) changed the title feat(log): add CONFLUENT_VERBOSITY and TTY color feat(log): add CONFLUENT_VERBOSITY and TTY color Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant