59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
var (
|
|
_logInfo *log.Logger
|
|
_logErr *log.Logger
|
|
_logWarn *log.Logger
|
|
_logConn *log.Logger
|
|
_logDebug *log.Logger
|
|
_logFatal *log.Logger
|
|
)
|
|
|
|
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)
|
|
_logDebug = log.New(os.Stdout, "DEBUG: ", log.Lmsgprefix|log.Ldate|log.Ltime)
|
|
_logFatal = log.New(os.Stdout, "FATAL: ", log.Lmsgprefix|log.Ldate|log.Ltime)
|
|
}
|
|
|
|
func logInfo(s ...interface{}) {
|
|
if settings.LogLevel >= 1 {
|
|
_logInfo.Print(s...)
|
|
}
|
|
}
|
|
|
|
func logErr(s ...interface{}) {
|
|
if settings.LogLevel >= 2 {
|
|
_logErr.Print(s...)
|
|
}
|
|
}
|
|
|
|
func logWarn(s ...interface{}) {
|
|
if settings.LogLevel >= 3 {
|
|
_logWarn.Print(s...)
|
|
}
|
|
}
|
|
|
|
func logConn(s ...interface{}) {
|
|
if settings.LogLevel >= 4 {
|
|
_logConn.Print(s...)
|
|
}
|
|
}
|
|
|
|
func logDebug(s ...interface{}) {
|
|
if settings.LogLevel >= 5 {
|
|
_logDebug.Print(s...)
|
|
}
|
|
}
|
|
|
|
func logFatal(s ...interface{}) {
|
|
_logFatal.Fatal(s...)
|
|
}
|