Skip to content

Commit 4120f94

Browse files
committed
child logger context reset and create a copy
1 parent 884a22c commit 4120f94

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

log.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ func NewWithContext(cfg *config.Config, ctx Fields) (*Logger, error) {
176176
// Also you can use method `AddContext` to context to the current logger.
177177
func (l *Logger) New(fields Fields) *Logger {
178178
nl := *l
179+
nl.ctx = make(Fields)
180+
nl.AddContext(l.ctx)
179181
nl.AddContext(fields)
180182
return &nl
181183
}
@@ -476,6 +478,7 @@ func (l *Logger) output(e *Entry) {
476478
l.receiver.Log(e)
477479

478480
// Execute logger hooks
481+
fmt.Println("Hooks:", l.hooks)
479482
go l.executeHooks(*e)
480483
}
481484

0 commit comments

Comments
 (0)