diff --git a/logger.go b/logger.go index 5ff0aef..cc81637 100644 --- a/logger.go +++ b/logger.go @@ -68,6 +68,10 @@ func (mw *MutexWrap) Unlock() { } } +func (mw *MutexWrap) Enable() { + mw.disabled = false +} + func (mw *MutexWrap) Disable() { mw.disabled = true } @@ -346,6 +350,18 @@ func (logger *Logger) Exit(code int) { } logger.ExitFunc(code) } +func (logger *Logger) Lock() { + logger.mu.Lock() +} +func (logger *Logger) Unlock() { + logger.mu.Unlock() +} + +// When an implementer is manipulating the logger concurrently, the +// implementer should call `SetYesLock` to enable the locking mechanism +func (logger *Logger) SetYesLock() { + logger.mu.Enable() +} //When file is opened with appending mode, it's safe to //write concurrently to a file (within 4k message on Linux).