From c830992a61feb7c379da5708645b44cf27041a02 Mon Sep 17 00:00:00 2001 From: Aditya Mukerjee Date: Fri, 4 Aug 2017 13:00:43 -0400 Subject: [PATCH] Take lock on mutex when firing hooks --- entry.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/entry.go b/entry.go index 5bf582e..1fad45e 100644 --- a/entry.go +++ b/entry.go @@ -94,7 +94,10 @@ func (entry Entry) log(level Level, msg string) { entry.Level = level entry.Message = msg - if err := entry.Logger.Hooks.Fire(level, &entry); err != nil { + entry.Logger.mu.Lock() + err := entry.Logger.Hooks.Fire(level, &entry) + entry.Logger.mu.Unlock() + if err != nil { entry.Logger.mu.Lock() fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err) entry.Logger.mu.Unlock()