Skip to content

Instantly share code, notes, and snippets.

@kamatama41
Created January 27, 2021 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamatama41/435d3fc5c6f3c06fcbba195bfae1bf95 to your computer and use it in GitHub Desktop.
Save kamatama41/435d3fc5c6f3c06fcbba195bfae1bf95 to your computer and use it in GitHub Desktop.
zapでログレベル変える
func init() {
conf := zap.NewProductionConfig()
logLevel := zap.InfoLevel
if l, ok := os.LookupEnv("LOG_LEVEL"); ok {
if err := logLevel.UnmarshalText([]byte(l)); err != nil {
panic(err)
}
}
conf.Level = zap.NewAtomicLevelAt(logLevel)
logger, err := conf.Build()
if err != nil {
panic(err)
}
logger.Info("hello")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment