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

Provide a discard-or-enabled logging adapter creation function #14

Open
kzantow opened this issue May 21, 2024 · 0 comments
Open

Provide a discard-or-enabled logging adapter creation function #14

kzantow opened this issue May 21, 2024 · 0 comments

Comments

@kzantow
Copy link
Contributor

kzantow commented May 21, 2024

There are some scenarios, for example: when running tests, when it would be nice to elevate the logging level. In Stereoscope, Syft and Grype this is created using the discard.New() constructor and returns a logger which doesn't log anything.

When looking at a Grype test issue, it became clear that we could not enable this logging level for the tests without modifying the code. Additionally, since Syft and Grype have different logger packages, we couldn't set this up in a Grype log package's init() function, as this wouldn't be called all the time and Syft's logger would remain the discard.

It would be great if there was a new function, something like discard.NewWithEnvironmentOverride() that would check for the presence of a consistent environment variable, for example something reasonably difficult to accidentally set like ANCHORE_GO_LOGGER_DEV_TEST_LEVEL to set a logging level such that logging can be enabled during tests or by default.

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

No branches or pull requests

1 participant