Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
06d888e8de | ||
![]() |
f6c7d66376 | ||
![]() |
7f0c64fd8a |
@@ -1,75 +0,0 @@
|
|||||||
{
|
|
||||||
"settings": {
|
|
||||||
"index": {
|
|
||||||
"mapping": {
|
|
||||||
"source": {
|
|
||||||
"mode": "synthetic"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"caller": {
|
|
||||||
"type": "text",
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"created_at": {
|
|
||||||
"type": "date",
|
|
||||||
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||epoch_second"
|
|
||||||
},
|
|
||||||
"level": {
|
|
||||||
"type": "text",
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"log": {
|
|
||||||
"properties": {
|
|
||||||
"at": {
|
|
||||||
"type": "date",
|
|
||||||
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||epoch_second"
|
|
||||||
},
|
|
||||||
"log_type": {
|
|
||||||
"type": "text",
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"param": {
|
|
||||||
"type": "text",
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"type": "text",
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"title": {
|
|
||||||
"type": "text",
|
|
||||||
"fields": {
|
|
||||||
"keyword": {
|
|
||||||
"type": "keyword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
42
log/log.go
42
log/log.go
@@ -3,7 +3,7 @@ package log
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -36,8 +36,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Operator struct {
|
type Operator struct {
|
||||||
ID int // 系统ID设置0
|
ID int `json:"id"` // 系统ID设置0
|
||||||
OperatorType OperatorType
|
OperatorType OperatorType `json:"operator_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LogInfo struct {
|
type LogInfo struct {
|
||||||
@@ -91,48 +91,48 @@ func ZapFatal(logger *zap.Logger, log *LogInfo) {
|
|||||||
|
|
||||||
func HandleLog(log *LogInfo) {
|
func HandleLog(log *LogInfo) {
|
||||||
// 处理 Param
|
// 处理 Param
|
||||||
//log.Param = processValue(log.Param)
|
log.Param = processValue(log.Param)
|
||||||
// 处理 Result
|
// 处理 Result
|
||||||
log.Result = processValue(log.Result)
|
log.Result = processValue(log.Result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GFInfo(ctx context.Context, log *LogInfo) {
|
func GFInfo(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||||
HandleLog(log)
|
HandleLog(log)
|
||||||
g.Log().Info(ctx, log)
|
g.Info(ctx, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GFWarning(ctx context.Context, log *LogInfo) {
|
func GFWarning(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||||
HandleLog(log)
|
HandleLog(log)
|
||||||
g.Log().Warning(ctx, log)
|
g.Warning(ctx, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GFError(ctx context.Context, log *LogInfo) {
|
func GFError(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||||
HandleLog(log)
|
HandleLog(log)
|
||||||
g.Log().Error(ctx, log)
|
g.Error(ctx, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GFDebug(ctx context.Context, log *LogInfo) {
|
func GFDebug(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||||
HandleLog(log)
|
HandleLog(log)
|
||||||
g.Log().Debug(ctx, log)
|
g.Debug(ctx, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GFPanic(ctx context.Context, log *LogInfo) {
|
func GFPanic(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||||
HandleLog(log)
|
HandleLog(log)
|
||||||
g.Log().Panic(ctx, log)
|
g.Panic(ctx, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GFFatal(ctx context.Context, log *LogInfo) {
|
func GFFatal(ctx context.Context, g *glog.Logger, log *LogInfo) {
|
||||||
HandleLog(log)
|
HandleLog(log)
|
||||||
g.Log().Fatal(ctx, log)
|
g.Fatal(ctx, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LogInfo) GFCommonHandelResult(ctx context.Context, result interface{}, err error) {
|
func (l *LogInfo) GFCommonHandelResult(ctx context.Context, g *glog.Logger, result interface{}, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Result = err
|
l.Result = err
|
||||||
GFError(ctx, l)
|
GFError(ctx, g, l)
|
||||||
} else {
|
} else {
|
||||||
l.Result = result
|
l.Result = result
|
||||||
GFInfo(ctx, l)
|
GFInfo(ctx, g, l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,9 +150,5 @@ func processValue(value interface{}) interface{} {
|
|||||||
if value == nil {
|
if value == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if _, ok := value.(error); ok {
|
|
||||||
return fmt.Sprintf("%+v", value)
|
return fmt.Sprintf("%+v", value)
|
||||||
} else {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user