MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / RestLogInfo

Method RestLogInfo

module/service/iml.go:108–150  ·  view source on GitHub ↗
(ctx context.Context, serviceId string, logId string)

Source from the content-addressed store, hash-verified

106}
107
108func (i *imlServiceModule) RestLogInfo(ctx context.Context, serviceId string, logId string) (*service_dto.RestLogInfo, error) {
109 c, err := i.clusterService.Get(ctx, cluster.DefaultClusterID)
110 if err != nil {
111 return nil, fmt.Errorf("cluster %s not found", cluster.DefaultClusterID)
112 }
113 info, err := i.logService.LogInfo(ctx, "loki", c.Cluster, logId)
114 if err != nil {
115 return nil, err
116 }
117 if info.Service != serviceId {
118 return nil, errors.New("service not match")
119 }
120
121 logInfo := &service_dto.RestLogInfo{
122 Id: info.ID,
123 API: auto.UUID(info.API),
124 Consumer: auto.UUID(info.Consumer),
125 Status: info.StatusCode,
126 Ip: info.RemoteIP,
127 ResponseTime: common.FormatTime(info.ResponseTime),
128 Traffic: common.FormatByte(info.Traffic),
129 LogTime: auto.TimeLabel(info.RecordTime),
130 Request: service_dto.OriginRequest{
131 Header: formatHeader(info.RequestHeader),
132 Origin: info.RequestBody,
133 Body: info.RequestBody,
134 },
135 Response: service_dto.OriginRequest{
136 Header: formatHeader(info.ResponseHeader),
137 Origin: info.ResponseBody,
138 Body: info.ResponseBody,
139 },
140 }
141
142 if info.Consumer == "apipark-global" {
143 logInfo.IsSystemConsumer = true
144 logInfo.Consumer = auto.Label{
145 Id: info.Consumer,
146 Name: "System Consumer",
147 }
148 }
149 return logInfo, nil
150}
151
152func (i *imlServiceModule) AILogInfo(ctx context.Context, serviceId string, logId string) (*service_dto.AILogInfo, error) {
153 c, err := i.clusterService.Get(ctx, cluster.DefaultClusterID)

Callers

nothing calls this directly

Calls 5

FormatTimeFunction · 0.92
FormatByteFunction · 0.92
formatHeaderFunction · 0.85
GetMethod · 0.65
LogInfoMethod · 0.65

Tested by

no test coverage detected