Skip to content

Commit

Permalink
Simplify copies
Browse files Browse the repository at this point in the history
  • Loading branch information
rs committed Sep 3, 2017
1 parent 2609401 commit 3ac71fc
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (l Logger) Output(w io.Writer) Logger {
l2 := New(w)
l2.level = l.level
l2.sampler = l.sampler
l2.context = make([]byte, len(l.context))
l2.context = make([]byte, len(l.context), cap(l.context))
copy(l2.context, l.context)
return l2
}
Expand Down Expand Up @@ -191,25 +191,14 @@ func (l *Logger) UpdateContext(update func(c Context) Context) {

// Level creates a child logger with the minimum accepted level set to level.
func (l Logger) Level(lvl Level) Logger {
return Logger{
w: l.w,
level: lvl,
sampler: l.sampler,
context: l.context,
}
l.level = lvl
return l
}

// Sample returns a logger with the s sampler.
func (l Logger) Sample(s Sampler) Logger {
if l.sampler == s {
return l
}
return Logger{
w: l.w,
level: l.level,
sampler: s,
context: l.context,
}
l.sampler = s
return l
}

// Debug starts a new message with debug level.
Expand Down

0 comments on commit 3ac71fc

Please sign in to comment.