forked from mirror/logrus
fix deadlock in previous entry race condition fix
This commit is contained in:
parent
b28acda22d
commit
ba670baee1
5
entry.go
5
entry.go
|
@ -219,8 +219,7 @@ func (entry Entry) HasCaller() (has bool) {
|
||||||
// This function is not declared with a pointer value because otherwise
|
// This function is not declared with a pointer value because otherwise
|
||||||
// race conditions will occur when using multiple goroutines
|
// race conditions will occur when using multiple goroutines
|
||||||
func (entry Entry) log(level Level, msg string) {
|
func (entry Entry) log(level Level, msg string) {
|
||||||
entry.Logger.mu.Lock()
|
|
||||||
defer entry.Logger.mu.Unlock()
|
|
||||||
var buffer *bytes.Buffer
|
var buffer *bytes.Buffer
|
||||||
|
|
||||||
// Default to now, but allow users to override if they want.
|
// Default to now, but allow users to override if they want.
|
||||||
|
@ -234,9 +233,11 @@ func (entry Entry) log(level Level, msg string) {
|
||||||
|
|
||||||
entry.Level = level
|
entry.Level = level
|
||||||
entry.Message = msg
|
entry.Message = msg
|
||||||
|
entry.Logger.mu.Lock()
|
||||||
if entry.Logger.ReportCaller {
|
if entry.Logger.ReportCaller {
|
||||||
entry.Caller = getCaller()
|
entry.Caller = getCaller()
|
||||||
}
|
}
|
||||||
|
entry.Logger.mu.Unlock()
|
||||||
|
|
||||||
entry.fireHooks()
|
entry.fireHooks()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue