logger.go
609 字节
package log
import (
"github.com/astaxie/beego/logs"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/constant"
)
func init() {
logs.SetLevel(logLevel(constant.LOG_LEVEL))
logs.SetLogFuncCall(false)
logs.SetLogger("file", `{"filename":"log/partnermg.log"}`)
logs.Async()
logs.Async(2 * 1e3)
}
//LogLevel ...
func logLevel(s string) (i int) {
switch s {
case "info":
i = logs.LevelInfo
case "debug":
i = logs.LevelDebug
case "warning":
i = logs.LevelWarning
case "error":
i = logs.LevelError
default:
i = logs.LevelDebug
}
return
}
func PrintSql(bt []byte) {
logs.Debug(string(bt))
}