Skip to content

Commit fc26014

Browse files
authored
MsgFunc function added to Event (#406)
Allows lazy evaluation of msg text, only if log level is appropriate.
1 parent 025f9f1 commit fc26014

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

event.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ func (e *Event) Msgf(format string, v ...interface{}) {
129129
e.msg(fmt.Sprintf(format, v...))
130130
}
131131

132+
func (e *Event) MsgFunc(createMsg func() string) {
133+
if e == nil {
134+
return
135+
}
136+
e.msg(createMsg())
137+
}
138+
132139
func (e *Event) msg(msg string) {
133140
for _, hook := range e.ch {
134141
hook.Run(e, e.level, msg)

0 commit comments

Comments
 (0)