Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: still warn on zero verbosity #68

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

willmurphyscode
Copy link
Contributor

Relates to anchore/grype#2180 and anchore/syft#3081.

This PR makes 2 changes:

  1. If no TTY is present, and neither --verbose nor --quiet is set, log.Warn should be written to stderr.
  2. Allow the environment variables NO_TTY to be set to force disabling the fancy terminal UI even if a TTY is present.

Number 1 will fix the linked bugs in Syft and Grype when this change is pulled into those repositories. Number 2 might be implemented differently or even removed - it really exists to enable testing bugs like number 1.

Previously, there was an issue where if there was no TTY, and verbosity
was zero, the logger would be initialized with io.Discard instead of
stderr. Log to stderr unless "--quiet" is passed.

Signed-off-by: Will Murphy <[email protected]>
@willmurphyscode willmurphyscode self-assigned this Oct 17, 2024
@@ -41,7 +41,7 @@ func DefaultLogger(clioCfg Config, store redact.Store) (logger.Logger, error) {

l, err := logrus.New(
logrus.Config{
EnableConsole: cfg.Verbosity > 0 && !cfg.Quiet,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the problem that cfg.Verbosity is never set, so defaults to 0 and therefore EnableConsole == false? Is there a way that this configuration could be consolidated to just be based on a verbosity number instead of 3 distinct settings of verbosity, quiet, and level?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

2 participants