Commit c1877c32 authored by Cloud User's avatar Cloud User

log query

parent 705b5847
...@@ -922,14 +922,21 @@ func main() { ...@@ -922,14 +922,21 @@ func main() {
taskId := c.Params("taskId") taskId := c.Params("taskId")
baseAttributes := []slog.Attr{}
baseAttributes = append(baseAttributes, slog.String(TaskIdAtrr, taskId))
newAttributes := append(baseAttributes, slog.String("c.Path()", c.Path()), slog.String("c.Route().Path", c.Route().Path))
slog.LogAttrs(c.UserContext(), slog.LevelInfo, "http api query task", newAttributes...)
if len(taskId) == 0 { if len(taskId) == 0 {
return c.SendString(fmt.Sprintf("%s must provide task id param for route %s ; e.g. http://127.0.0.1/query/v1/e45b5ebc-c71e-4ab8-b10f-d1202e7fb16e ", c.Path(), c.Route().Path)) return c.SendString(fmt.Sprintf("%s must provide task id param for route %s ; e.g. http://127.0.0.1/query/v1/e45b5ebc-c71e-4ab8-b10f-d1202e7fb16e ", c.Path(), c.Route().Path))
} }
if res, ok := getAsyncRes(taskId); ok { if res, ok := getAsyncRes(taskId); ok {
baseAttributes := []slog.Attr{} // baseAttributes := []slog.Attr{}
baseAttributes = append(baseAttributes, slog.String(TaskIdAtrr, taskId)) // baseAttributes = append(baseAttributes, slog.String(TaskIdAtrr, taskId))
newAttributes := append(baseAttributes, slog.Int("resAsPb.TaskResultCode", int(res.TaskResultCode)), slog.String("TaskResultHeader", string(res.TaskResultHeader))) newAttributes := append(baseAttributes, slog.Int("resAsPb.TaskResultCode", int(res.TaskResultCode)), slog.String("TaskResultHeader", string(res.TaskResultHeader)))
slog.LogAttrs(c.UserContext(), slog.LevelInfo, "getAsyncRes", newAttributes...) slog.LogAttrs(c.UserContext(), slog.LevelInfo, "getAsyncRes", newAttributes...)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment