diff --git a/cmd/logs_query.go b/cmd/logs_query.go index 0fb8c3b..d7dee58 100644 --- a/cmd/logs_query.go +++ b/cmd/logs_query.go @@ -51,10 +51,12 @@ var logsQueryCmd = &cobra.Command{ req := client.NewRequest(` query FetchLogs($request: FetchLogRequest!) { logs_list(request: $request) { - timestamp - severity - message - labels + logs { + timestamp + severity + message + labels + } } } `) @@ -70,11 +72,13 @@ var logsQueryCmd = &cobra.Command{ req.Var("request", requestVars) var respData struct { - LogsList []struct { - Timestamp string `json:"timestamp"` - Severity string `json:"severity"` - Message string `json:"message"` - Labels json.RawMessage `json:"labels"` + LogsList struct { + Logs []struct { + Timestamp string `json:"timestamp"` + Severity string `json:"severity"` + Message string `json:"message"` + Labels json.RawMessage `json:"labels"` + } `json:"logs"` } `json:"logs_list"` } @@ -82,13 +86,13 @@ var logsQueryCmd = &cobra.Command{ return err } - if len(respData.LogsList) == 0 { + if len(respData.LogsList.Logs) == 0 { fmt.Println("No logs found.") return nil } table := format.TabularData{ - Data: respData.LogsList, + Data: respData.LogsList.Logs, Fields: []format.TableField{ {Header: "Timestamp", Field: "Timestamp"}, {Header: "Severity", Field: "Severity"}, diff --git a/cmd/logs_query_test.go b/cmd/logs_query_test.go index 2e8228a..cde7e53 100644 --- a/cmd/logs_query_test.go +++ b/cmd/logs_query_test.go @@ -8,12 +8,14 @@ import ( func TestLogsQuery_Unit(t *testing.T) { mockData := map[string]any{ - "logs_list": []map[string]any{ - { - "timestamp": "2025-10-15T10:00:00Z", - "severity": "info", - "message": "Log message 1", - "labels": "{}", + "logs_list": map[string]any{ + "logs": []map[string]any{ + { + "timestamp": "2025-10-15T10:00:00Z", + "severity": "info", + "message": "Log message 1", + "labels": "{}", + }, }, }, }