Created
January 27, 2021 23:34
-
-
Save kamatama41/435d3fc5c6f3c06fcbba195bfae1bf95 to your computer and use it in GitHub Desktop.
zapでログレベル変える
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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