mirror of https://github.com/sirupsen/logrus.git
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:
parent
d1e6332644
commit
6ad9bc4e97
16
logger.go
16
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).
|
||||
|
|
Loading…
Reference in New Issue