mirror of https://github.com/sirupsen/logrus.git
Make log method receive a copy of Entry structure to avoid race
conditions Fixes #216 Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
parent
8bca266407
commit
396f8eefaa
4
entry.go
4
entry.go
|
@ -70,12 +70,12 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
|
|||
return &Entry{Logger: entry.Logger, Data: data}
|
||||
}
|
||||
|
||||
func (entry *Entry) log(level Level, msg string) {
|
||||
func (entry Entry) log(level Level, msg string) {
|
||||
entry.Time = time.Now()
|
||||
entry.Level = level
|
||||
entry.Message = msg
|
||||
|
||||
if err := entry.Logger.Hooks.Fire(level, entry); err != nil {
|
||||
if err := entry.Logger.Hooks.Fire(level, &entry); err != nil {
|
||||
entry.Logger.mu.Lock()
|
||||
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
|
||||
entry.Logger.mu.Unlock()
|
||||
|
|
Loading…
Reference in New Issue