2026-05-02 23:39:10 +08:00
|
|
|
package log
|
|
|
|
|
|
|
|
|
|
const LogTypeDebug = "debug"
|
|
|
|
|
const LogTypeInfo = "info"
|
|
|
|
|
const LogTypeWarning = "warning"
|
|
|
|
|
const LogTypeError = "error"
|
|
|
|
|
const LogTypeUndefined = "undefined"
|
|
|
|
|
const LogTypeDb = "db"
|
|
|
|
|
const LogTypeDbError = "dbError"
|
|
|
|
|
const LogTypeServer = "server"
|
|
|
|
|
const LogTypeServerError = "serverError"
|
|
|
|
|
const LogTypeTask = "task"
|
|
|
|
|
const LogTypeMonitor = "monitor"
|
|
|
|
|
const LogTypeStatistic = "statistic"
|
|
|
|
|
const LogTypeRequest = "request"
|
|
|
|
|
|
|
|
|
|
const LogDefaultSensitive = "phone,password,secret,token,accessToken"
|
|
|
|
|
const LogEnvLevel = "LOG_LEVEL"
|
|
|
|
|
const LogEnvFile = "LOG_FILE"
|
|
|
|
|
const LogEnvSensitive = "LOG_SENSITIVE"
|
|
|
|
|
const LogEnvRegexSensitive = "LOG_REGEXSENSITIVE"
|
|
|
|
|
|
|
|
|
|
type BaseLog struct {
|
|
|
|
|
LogName string
|
|
|
|
|
LogType string
|
|
|
|
|
LogTime string
|
|
|
|
|
TraceId string
|
|
|
|
|
ImageName string
|
|
|
|
|
ImageTag string
|
|
|
|
|
ServerName string
|
|
|
|
|
ServerIp string
|
2026-05-04 09:57:29 +08:00
|
|
|
Extra map[string]any
|
2026-05-02 23:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-04 09:57:29 +08:00
|
|
|
func (b *BaseLog) IsLogEntry() bool {
|
|
|
|
|
return true
|
2026-05-02 23:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type DebugLog struct {
|
|
|
|
|
BaseLog
|
|
|
|
|
Debug string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type InfoLog struct {
|
|
|
|
|
BaseLog
|
|
|
|
|
Info string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type WarningLog struct {
|
|
|
|
|
BaseLog
|
|
|
|
|
Warning string
|
|
|
|
|
CallStacks []string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ErrorLog struct {
|
|
|
|
|
BaseLog
|
|
|
|
|
Error string
|
|
|
|
|
CallStacks []string
|
|
|
|
|
}
|