Skip to content

Commit

Permalink
feat: add WithHook to customize the hook function for zerolog
Browse files Browse the repository at this point in the history
  • Loading branch information
lovung committed Jan 27, 2024
1 parent 8af1031 commit 4179a32
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions logging/zerolog/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ func WithRecordStackTraceInSpan(recordStackTraceInSpan bool) Option {
})
}

// WithHook configure a custom hook function option
func WithHook(fn zerolog.HookFunc) Option {
return option(func(cfg *config) {
cfg.hookFunc = fn
})
}

func (cfg config) getZerologHookFn() zerolog.HookFunc {
if cfg.hookFunc != nil {
return cfg.hookFunc
Expand Down

0 comments on commit 4179a32

Please sign in to comment.