From 3d1341ce2c22580f905a6422decdffc688ffbb08 Mon Sep 17 00:00:00 2001 From: Aditya Mukerjee Date: Fri, 4 Aug 2017 11:24:22 -0400 Subject: [PATCH] Add AddHook method for logger --- logger.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/logger.go b/logger.go index 2acab05..fdaf8a6 100644 --- a/logger.go +++ b/logger.go @@ -315,3 +315,9 @@ func (logger *Logger) level() Level { func (logger *Logger) SetLevel(level Level) { atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) } + +func (logger *Logger) AddHook(hook Hook) { + logger.mu.Lock() + defer logger.mu.Unlock() + logger.Hooks.Add(hook) +}