Skip to content

Commit

Permalink
copy leveled outputs on Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Sep 6, 2020
1 parent c0e998b commit 735a583
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion logger.go
Expand Up @@ -497,13 +497,19 @@ func (l *Logger) Scan(r io.Reader) (cancel func()) {
// Clone returns a copy of this "l" Logger.
// This copy is returned as pointer as well.
func (l *Logger) Clone() *Logger {
// copy level output map.
levelOutput := make(map[Level]io.Writer, len(l.LevelOutput))
for k, v := range l.LevelOutput {
levelOutput[k] = v
}

return &Logger{
Prefix: l.Prefix,
Level: l.Level,
TimeFormat: l.TimeFormat,
NewLine: l.NewLine,
Printer: l.Printer,
LevelOutput: l.LevelOutput,
LevelOutput: levelOutput,
handlers: l.handlers,
children: newLoggerMap(),
mu: sync.Mutex{},
Expand Down

0 comments on commit 735a583

Please sign in to comment.