Exposed Lock functionality/controls

When implementers are managing multiple applications within a single service, multiple logrus instances are used. These services can have different subset configurations such as Minimum level assignment.
This commit is contained in:
Unafilliate Code 2024-11-28 16:52:25 -05:00
parent d1e6332644
commit 6ad9bc4e97
1 changed files with 16 additions and 0 deletions

View File

@ -68,6 +68,10 @@ func (mw *MutexWrap) Unlock() {
} }
} }
func (mw *MutexWrap) Enable() {
mw.disabled = false
}
func (mw *MutexWrap) Disable() { func (mw *MutexWrap) Disable() {
mw.disabled = true mw.disabled = true
} }
@ -346,6 +350,18 @@ func (logger *Logger) Exit(code int) {
} }
logger.ExitFunc(code) 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 //When file is opened with appending mode, it's safe to
//write concurrently to a file (within 4k message on Linux). //write concurrently to a file (within 4k message on Linux).