matrix-prometheus/vendor/git.luj0ga.de/franconian/matrix/logger.go

39 lines
692 B
Go
Raw Normal View History

2023-01-13 21:24:39 +01:00
package matrix
import (
"fmt"
"log"
)
type logger struct{
Level uint
}
func (l logger) Error(message string, args ...interface{}) {
if l.Level > 0 {
logLevel("error", message, args...)
}
}
func (l logger) Warn(message string, args ...interface{}) {
if l.Level > 1 {
logLevel("warning", message, args...)
}
}
func (l logger) Debug(message string, args ...interface{}) {
if l.Level > 2 {
logLevel("debug", message, args...)
}
}
func (l logger) Trace(message string, args ...interface{}) {
if l.Level > 3 {
logLevel("trace", message, args...)
}
}
func logLevel(level, message string, args ...interface{}) {
log.Print("[", level, "] ", fmt.Sprintf(message, args...))
}