Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed Lock functionality/controls #1449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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