MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / InsertLog

Method InsertLog

service/log/iml.go:64–97  ·  view source on GitHub ↗
(ctx context.Context, driver string, input *InsertLog)

Source from the content-addressed store, hash-verified

62}
63
64func (i *imlLogService) InsertLog(ctx context.Context, driver string, input *InsertLog) error {
65 // 判断日志是否已存在,若已存在,则不插入
66 _, err := i.logRecordStore.First(ctx, map[string]interface{}{"uuid": input.ID})
67 if err != nil {
68 if !errors.Is(err, gorm.ErrRecordNotFound) {
69 log_print.Errorf("get log record %s error: %s", input.ID, err)
70 return err
71 }
72 return i.logRecordStore.Insert(ctx, &log_source.LogRecord{
73 UUID: input.ID,
74 Driver: input.Driver,
75 Service: input.Service,
76 API: input.API,
77 Strategy: input.Strategy,
78 Method: input.Method,
79 Url: input.Url,
80 RemoteIP: input.RemoteIP,
81 Consumer: input.Consumer,
82 Authorization: input.Authorization,
83 InputToken: input.InputToken,
84 OutputToken: input.OutputToken,
85 TotalToken: input.TotalToken,
86 AIProvider: input.AIProvider,
87 AIModel: input.AIModel,
88 StatusCode: input.StatusCode,
89 ResponseTime: input.ResponseTime,
90
91 Traffic: input.Traffic,
92 RecordTime: input.RecordTime,
93 })
94 }
95 return nil
96
97}
98
99func (i *imlLogService) OnComplete() {
100 drivers := log_driver.Drivers()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected