59 lines
1.2 KiB
Go
Raw Normal View History

2021-01-17 04:17:15 +00:00
package main
import (
"log"
"os"
)
var (
_logInfo *log.Logger
2021-02-11 21:05:01 +00:00
_logErr *log.Logger
_logWarn *log.Logger
_logConn *log.Logger
_logDebug *log.Logger
_logFatal *log.Logger
2021-01-17 04:17:15 +00:00
)
func logInit() {
_logInfo = log.New(os.Stdout, "INFO: ", log.Lmsgprefix|log.Ldate|log.Ltime)
_logErr = log.New(os.Stdout, "ERR: ", log.Lmsgprefix|log.Ldate|log.Ltime)
_logWarn = log.New(os.Stdout, "WARN: ", log.Lmsgprefix|log.Ldate|log.Ltime)
_logConn = log.New(os.Stdout, "CONN: ", log.Lmsgprefix|log.Ldate|log.Ltime)
2021-02-11 21:05:01 +00:00
_logDebug = log.New(os.Stdout, "DEBUG: ", log.Lmsgprefix|log.Ldate|log.Ltime)
_logFatal = log.New(os.Stdout, "FATAL: ", log.Lmsgprefix|log.Ldate|log.Ltime)
2021-02-11 21:05:01 +00:00
}
func logInfo(s ...interface{}) {
if settings.LogLevel >= 1 {
2021-02-11 21:05:01 +00:00
_logInfo.Print(s...)
}
}
func logErr(s ...interface{}) {
if settings.LogLevel >= 2 {
2021-02-11 21:05:01 +00:00
_logErr.Print(s...)
}
}
func logWarn(s ...interface{}) {
if settings.LogLevel >= 3 {
2021-02-11 21:05:01 +00:00
_logWarn.Print(s...)
}
}
func logConn(s ...interface{}) {
if settings.LogLevel >= 4 {
2021-02-11 21:05:01 +00:00
_logConn.Print(s...)
}
}
func logDebug(s ...interface{}) {
if settings.LogLevel >= 5 {
_logDebug.Print(s...)
2021-02-11 21:05:01 +00:00
}
2021-01-17 04:17:15 +00:00
}
func logFatal(s ...interface{}) {
_logFatal.Fatal(s...)
}