Skip to content

Commit 84c35e6

Browse files
feat(enterprise): implement logs command for cluster event retrieval (#241)
* feat(enterprise): implement logs command for cluster event retrieval - Add LogsCommands enum with List subcommand for retrieving cluster logs - Support query parameters: stime, etime, order, limit, offset - Fix LogEntry structure to match actual API (time, type, extra fields) - Update LogsQuery to use correct API parameters - Add comprehensive tests for all query parameter combinations - Wire up command in main enterprise command structure Note: Only implements GET /v1/logs endpoint as that's the only logs endpoint that exists in the Redis Enterprise API. Issue #157 requests features that don't exist in the API (node/database specific logs, log files, rotation, etc.) * chore: clean up logs implementation - Remove unnecessary #[allow(dead_code)] attribute - Add module documentation * chore: add #[allow(dead_code)] to match cloud implementation pattern Suppress false positive warnings for functions that are used by the binary but appear unused from the library's perspective.
1 parent 46f7607 commit 84c35e6

File tree

7 files changed

+280
-250
lines changed

7 files changed

+280
-250
lines changed

crates/redis-enterprise/src/logs.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,34 @@ use crate::error::Result;
1010
use serde::{Deserialize, Serialize};
1111
use serde_json::Value;
1212

13-
/// Log entry
13+
/// Log entry (cluster event)
1414
#[derive(Debug, Clone, Serialize, Deserialize)]
1515
pub struct LogEntry {
16-
pub id: u64,
16+
/// Timestamp when event happened
1717
pub time: String,
18-
pub level: String,
19-
pub component: Option<String>,
20-
pub message: String,
21-
pub node_uid: Option<u32>,
22-
pub bdb_uid: Option<u32>,
23-
pub user: Option<String>,
2418

19+
/// Event type - determines what additional fields are available
20+
#[serde(rename = "type")]
21+
pub event_type: String,
22+
23+
/// Additional fields based on event type
2524
#[serde(flatten)]
2625
pub extra: Value,
2726
}
2827

2928
/// Logs query parameters
30-
#[derive(Debug, Serialize)]
29+
#[derive(Debug, Serialize, Default)]
3130
pub struct LogsQuery {
3231
#[serde(skip_serializing_if = "Option::is_none")]
33-
pub limit: Option<u32>,
34-
#[serde(skip_serializing_if = "Option::is_none")]
35-
pub offset: Option<u32>,
32+
pub stime: Option<String>,
3633
#[serde(skip_serializing_if = "Option::is_none")]
37-
pub level: Option<String>,
34+
pub etime: Option<String>,
3835
#[serde(skip_serializing_if = "Option::is_none")]
39-
pub component: Option<String>,
36+
pub order: Option<String>,
4037
#[serde(skip_serializing_if = "Option::is_none")]
41-
pub node_uid: Option<u32>,
38+
pub limit: Option<u32>,
4239
#[serde(skip_serializing_if = "Option::is_none")]
43-
pub bdb_uid: Option<u32>,
40+
pub offset: Option<u32>,
4441
}
4542

4643
/// Logs handler for querying event logs
@@ -63,9 +60,4 @@ impl LogsHandler {
6360
self.client.get("/v1/logs").await
6461
}
6562
}
66-
67-
/// Get specific log entry
68-
pub async fn get(&self, id: u64) -> Result<LogEntry> {
69-
self.client.get(&format!("/v1/logs/{}", id)).await
70-
}
7163
}

0 commit comments

Comments
 (0)