Skip to content

Commit

Permalink
Exposed Lock functionality/controls
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
UnaffiliatedCode committed Nov 28, 2024
1 parent d1e6332 commit 6ad9bc4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func (mw *MutexWrap) Unlock() {
}
}

func (mw *MutexWrap) Enable() {
mw.disabled = false
}

func (mw *MutexWrap) Disable() {
mw.disabled = true
}
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 6ad9bc4

Please sign in to comment.