Fix a race conditions
Two accesses to a loggers were not protected by a logger's mutex
This commit is contained in:
parent
79da88fda7
commit
572fff1be4
1 changed files with 6 additions and 0 deletions
|
@ -28,11 +28,17 @@ func NewLogger(name string) (l *Logger) {
|
|||
|
||||
// AddBackend add a new Backend to the logger. All set backends are kept.
|
||||
func (l *Logger) AddBackend(b Backend) {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
|
||||
l.backends = append(l.backends, b)
|
||||
}
|
||||
|
||||
// SetBackend sets the backend list to the logger. Any existing backend will be lost.
|
||||
func (l *Logger) SetBackend(b ...Backend) {
|
||||
l.Lock()
|
||||
defer l.Unlock()
|
||||
|
||||
l.backends = b
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue