Last active
August 6, 2021 10:57
-
-
Save percybolmer/caeff67404b401d229a789a7399e26c5 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" | |
) | |
var ( | |
HelloCounter = 1 | |
logger zerolog.Logger | |
) | |
func main() { | |
// Build a logger with default fields | |
logger = log.With(). | |
Str("service", "my-service"). | |
Str("node", "localhost"). | |
Logger() | |
Hello() | |
Hello() | |
} | |
func Hello() { | |
// Log with service name | |
logger.Info(). | |
Int("count", HelloCounter). | |
Msg("Hello") | |
HelloCounter++ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment