1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-11-25 20:59:36 +01:00

Jeff saves the day

This commit is contained in:
binwiederhier 2023-02-09 19:45:02 -05:00
parent dc77efc31a
commit 057c4a3239
2 changed files with 14 additions and 14 deletions

View file

@ -197,9 +197,9 @@ func (e *Event) shouldLog(l Level) bool {
}
func (e *Event) globalLevelWithOverride() Level {
mu.Lock()
mu.RLock()
l, ov := level, overrides
mu.Unlock()
mu.RUnlock()
if e.fields == nil {
return l
}
@ -217,9 +217,9 @@ func (e *Event) globalLevelWithOverride() Level {
}
func (e *Event) maybeApplyContexters() bool {
mu.Lock()
mu.RLock()
hasOverrides := len(overrides) > 0
mu.Unlock()
mu.RUnlock()
if hasOverrides {
e.applyContexters()
}

View file

@ -20,7 +20,7 @@ var (
format = DefaultFormat
overrides = make(map[string]*levelOverride)
output io.Writer = DefaultOutput
mu = &sync.Mutex{}
mu = &sync.RWMutex{}
)
// Fatal prints the given message, and exits the program
@ -85,8 +85,8 @@ func Timing(f func()) *Event {
// CurrentLevel returns the current log level
func CurrentLevel() Level {
mu.Lock()
defer mu.Unlock()
mu.RLock()
defer mu.RUnlock()
return level
}
@ -111,10 +111,10 @@ func ResetLevelOverrides() {
overrides = make(map[string]*levelOverride)
}
// CurrentFormat returns the current log formt
// CurrentFormat returns the current log format
func CurrentFormat() Format {
mu.Lock()
defer mu.Unlock()
mu.RLock()
defer mu.RUnlock()
return format
}
@ -138,8 +138,8 @@ func SetOutput(w io.Writer) {
// File returns the log file, if any, or an empty string otherwise
func File() string {
mu.Lock()
defer mu.Unlock()
mu.RLock()
defer mu.RUnlock()
if f, ok := output.(*os.File); ok {
return f.Name()
}
@ -148,8 +148,8 @@ func File() string {
// IsFile returns true if the output is a non-default file
func IsFile() bool {
mu.Lock()
defer mu.Unlock()
mu.RLock()
defer mu.RUnlock()
if _, ok := output.(*os.File); ok && output != DefaultOutput {
return true
}