Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active August 6, 2021 10:56
Show Gist options
  • Save percybolmer/6de1b48f09e4015c1d98e8ed023b3007 to your computer and use it in GitHub Desktop.
Save percybolmer/6de1b48f09e4015c1d98e8ed023b3007 to your computer and use it in GitHub Desktop.
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