Skip to content

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

@kzantow

Description

@kzantow

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions