matrix/logger.go

39 lines
692 B
Go
Raw Normal View History

2022-08-10 22:33:35 +02: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...))
}