forked from rs/zerolog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds the Func log method to log using an anonymous function only if the level is currently enabled. The use case is for when you don't own an object and therefore can't create your own marshaller but need to do some translation prior to logging. For example, this: msg := log.Debug() if msg.Enabled() { msg.Str("complicated_thing", makeBinaryThingLoggable(thing)) } msg.Msg("Sending complicated thing") Turns into this: log.Debug(). Func(func(e *Event) { e.Str("complicated_thing", makeBinaryThingLoggable(thing)) }). Msg("Sending complicated thing")
- Loading branch information
Showing
3 changed files
with
12 additions
and
1 deletion.
There are no files selected for viewing
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
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
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