Lock mutex before formatting to avoid race

This commit is contained in:
Michael Haines 2018-02-05 12:44:11 -07:00
parent efbfdb5f09
commit eeb653535c
1 changed files with 1 additions and 1 deletions

View File

@ -123,9 +123,9 @@ func (entry *Entry) fireHooks() {
}
func (entry *Entry) write() {
serialized, err := entry.Logger.Formatter.Format(entry)
entry.Logger.mu.Lock()
defer entry.Logger.mu.Unlock()
serialized, err := entry.Logger.Formatter.Format(entry)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
} else {