Files
nCovTrack-Backend/utils/log.go
2022-01-23 18:28:01 +08:00

59 lines
1.3 KiB
Go

package utils
import "nCovTrack-Backend/global"
func RequestLogInfo(args ...interface{}) {
logInfo("request", args...)
}
func RequestLogError(args ...interface{}) {
logError("request", args...)
}
func RequestLogWarn(args ...interface{}) {
logWarn("request", args...)
}
func InitLogError(component string, args ...interface{}) {
args = append(args, "component", component)
logError("initialize", args...)
}
func InitLogInfo(component string, args ...interface{}) {
args = append(args, "component", component)
logInfo("initialize", args...)
}
func UtilLogInfo(utilName string, args ...interface{}) {
args = append(args, "util", utilName)
logInfo("util", args...)
}
func UtilLogError(utilName string, args ...interface{}) {
args = append(args, "util", utilName)
logError("util", args...)
}
func UtilLogWarn(utilName string, args ...interface{}) {
args = append(args, "util", utilName)
logWarn("util", args...)
}
func logInfo(msg string, args ...interface{}) {
if global.ServerSettings.Env != global.ENV_NOLOG {
global.Logger.Infow(msg, args...)
}
}
func logError(msg string, args ...interface{}) {
if global.ServerSettings.Env != global.ENV_NOLOG {
global.Logger.Errorw(msg, args...)
}
}
func logWarn(msg string, args ...interface{}) {
if global.ServerSettings.Env != global.ENV_NOLOG {
global.Logger.Warnw(msg, args...)
}
}