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

kit/log/levels: Support checking if a log level is enabled #324

Closed
hnakamur opened this issue Jul 18, 2016 · 1 comment
Closed

kit/log/levels: Support checking if a log level is enabled #324

hnakamur opened this issue Jul 18, 2016 · 1 comment

Comments

@hnakamur
Copy link

I read #250 and #269 and thought maybe a simpler approach should be enough.

I think it's important to avoid the execution cost of debug prints when a log level is disabled.
To achieve that, it is best to surround log printing statement with if.
For example, the following code

logger := levels.New(log.NewJSONFormatter(os.Stdout))
logger.Debug().Log("msg", "some debug stuff")

should be written as something like pseudo code

logger := levels.New(log.NewJSONFormatter(os.Stdout))
if the_debug_level_is_enabled() {
    logger.Debug().Log("msg", "some debug stuff")
}

I sent #322 to achieve this.

@hnakamur hnakamur changed the title Support checking if a log level is enabled kit/log/levels: Support checking if a log level is enabled Jul 18, 2016
@peterbourgon
Copy link
Member

Closed with #322

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

No branches or pull requests

2 participants