Skip to content

Commit

Permalink
fix deadlock in previous entry race condition fix
Browse files Browse the repository at this point in the history
  • Loading branch information
admacleod committed Mar 19, 2020
1 parent b28acda commit ba670ba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ func (entry Entry) HasCaller() (has bool) {
// This function is not declared with a pointer value because otherwise
// race conditions will occur when using multiple goroutines
func (entry Entry) log(level Level, msg string) {
entry.Logger.mu.Lock()
defer entry.Logger.mu.Unlock()

var buffer *bytes.Buffer

// Default to now, but allow users to override if they want.
Expand All @@ -234,9 +233,11 @@ func (entry Entry) log(level Level, msg string) {

entry.Level = level
entry.Message = msg
entry.Logger.mu.Lock()
if entry.Logger.ReportCaller {
entry.Caller = getCaller()
}
entry.Logger.mu.Unlock()

entry.fireHooks()

Expand Down

0 comments on commit ba670ba

Please sign in to comment.