52 lines
785 B
Go
52 lines
785 B
Go
package logger
|
|
|
|
import "log"
|
|
|
|
const (
|
|
Disabled = iota
|
|
InfoLevel
|
|
WarningLevel
|
|
DebugLevel
|
|
)
|
|
|
|
var loggerLevel int = InfoLevel
|
|
|
|
func SetLevel(level int) {
|
|
loggerLevel = level
|
|
}
|
|
|
|
func Info(v ...interface{}) {
|
|
if loggerLevel >= InfoLevel {
|
|
log.Println(v...)
|
|
}
|
|
}
|
|
|
|
func Infof(format string, v ...interface{}) {
|
|
if loggerLevel >= InfoLevel {
|
|
log.Printf(format, v...)
|
|
}
|
|
}
|
|
|
|
func Warning(v ...interface{}) {
|
|
if loggerLevel >= WarningLevel {
|
|
log.Println(v...)
|
|
}
|
|
}
|
|
|
|
func Warningf(format string, v ...interface{}) {
|
|
if loggerLevel >= WarningLevel {
|
|
log.Printf(format, v...)
|
|
}
|
|
}
|
|
|
|
func Debug(v ...interface{}) {
|
|
if loggerLevel >= DebugLevel {
|
|
log.Println(v...)
|
|
}
|
|
}
|
|
|
|
func Debugf(format string, v ...interface{}) {
|
|
if loggerLevel >= DebugLevel {
|
|
log.Printf(format, v...)
|
|
}
|
|
}
|