MCPcopy
hub / github.com/dnote/dnote / shouldLog

Function shouldLog

pkg/server/log/log.go:85–107  ·  view source on GitHub ↗

shouldLog returns true if the given level should be logged based on currentLevel. Log level behavior (hierarchical): - LevelDebug: shows all messages (debug, info, warn, error) - LevelInfo: shows info, warn, and error messages - LevelWarn: shows warn and error messages - LevelError: shows only erro

(level string)

Source from the content-addressed store, hash-verified

83// - LevelWarn: shows warn and error messages
84// - LevelError: shows only error messages
85func shouldLog(level string) bool {
86 // Debug level shows everything
87 if currentLevel == LevelDebug {
88 return true
89 }
90
91 // Info level shows info + warn + error
92 if currentLevel == LevelInfo {
93 return level == LevelInfo || level == LevelWarn || level == LevelError
94 }
95
96 // Warn level shows warn + error
97 if currentLevel == LevelWarn {
98 return level == LevelWarn || level == LevelError
99 }
100
101 // Error level shows only error
102 if currentLevel == LevelError {
103 return level == LevelError
104 }
105
106 return false
107}
108
109// Debug logs the given entry at a debug level
110func (e Entry) Debug(msg string) {

Callers 2

TestShouldLogFunction · 0.85
writeMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestShouldLogFunction · 0.68