Take lock on mutex when firing hooks

This commit is contained in:
Aditya Mukerjee 2017-08-04 13:00:43 -04:00
parent 66230b2871
commit c830992a61
1 changed files with 4 additions and 1 deletions

View File

@ -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()