Last active
August 6, 2021 10:56
-
-
Save percybolmer/6de1b48f09e4015c1d98e8ed023b3007 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"github.com/rs/zerolog" | |
"github.com/rs/zerolog/log" | |
) | |
func main() { | |
// Apply zerolog global level, this will stop zerolog from logging any debug messages | |
debug := false | |
// Apply log level in the beginning of the application | |
zerolog.SetGlobalLevel(zerolog.InfoLevel) | |
if debug { | |
zerolog.SetGlobalLevel(zerolog.DebugLevel) | |
} | |
// Log with service name | |
log.Info(). | |
Str("service", "my-service"). | |
Int("Some integer", 10). | |
Msg("Hello") | |
// Debug log | |
log.Debug().Msg("Exiting Program") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment