mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
Reorganize packages pt 1
End goal: simplify build process
This commit is contained in:
46
log/logging.go
Normal file
46
log/logging.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
type LogLevel int
|
||||
|
||||
const (
|
||||
ERROR LogLevel = iota
|
||||
WARN
|
||||
INFO
|
||||
TRACE
|
||||
)
|
||||
|
||||
var MaxLogLevel LogLevel = TRACE
|
||||
|
||||
// Error logs a message to the 'standard' Logger (always)
|
||||
func Error(msg string, args ...interface{}) {
|
||||
msg = "[ERROR] " + msg
|
||||
log.Printf(msg, args...)
|
||||
}
|
||||
|
||||
// Warn logs a message to the 'standard' Logger if MaxLogLevel is >= WARN
|
||||
func Warn(msg string, args ...interface{}) {
|
||||
if MaxLogLevel >= WARN {
|
||||
msg = "[WARN ] " + msg
|
||||
log.Printf(msg, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// Info logs a message to the 'standard' Logger if MaxLogLevel is >= INFO
|
||||
func Info(msg string, args ...interface{}) {
|
||||
if MaxLogLevel >= INFO {
|
||||
msg = "[INFO ] " + msg
|
||||
log.Printf(msg, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// Trace logs a message to the 'standard' Logger if MaxLogLevel is >= TRACE
|
||||
func Trace(msg string, args ...interface{}) {
|
||||
if MaxLogLevel >= TRACE {
|
||||
msg = "[TRACE] " + msg
|
||||
log.Printf(msg, args...)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user