logai/
lib.rs

1pub mod ai;
2pub mod analyzer;
3pub mod cli;
4pub mod commands;
5pub mod logging;
6pub mod mcp;
7pub mod output;
8pub mod parser;
9pub mod search;
10pub mod storage;
11
12pub use anyhow::{Error, Result};
13
14/// Core types used throughout the application
15pub mod types {
16    use chrono::{DateTime, Utc};
17    use serde::{Deserialize, Serialize};
18
19    #[derive(Debug, Clone, Serialize, Deserialize)]
20    pub struct LogEntry {
21        pub timestamp: Option<DateTime<Utc>>,
22        pub severity: Severity,
23        pub message: String,
24        pub metadata: LogMetadata,
25        pub raw: String,
26    }
27
28    #[derive(Debug, Clone, Serialize, Deserialize)]
29    pub struct LogMetadata {
30        pub file: Option<String>,
31        pub line: Option<u32>,
32        pub function: Option<String>,
33        pub thread: Option<String>,
34        pub extra: std::collections::HashMap<String, String>,
35    }
36
37    #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
38    pub enum Severity {
39        Error,
40        Warning,
41        Info,
42        Debug,
43        Trace,
44        Unknown,
45    }
46
47    #[derive(Debug, Clone, Serialize, Deserialize)]
48    pub struct ErrorGroup {
49        pub id: String,
50        pub pattern: String,
51        pub count: usize,
52        pub first_seen: DateTime<Utc>,
53        pub last_seen: DateTime<Utc>,
54        pub severity: Severity,
55        pub entries: Vec<LogEntry>,
56        pub analysis: Option<ErrorAnalysis>,
57    }
58
59    #[derive(Debug, Clone, Serialize, Deserialize)]
60    pub struct ErrorAnalysis {
61        pub explanation: String,
62        pub root_cause: Option<String>,
63        #[serde(default)]
64        pub suggestions: Vec<Suggestion>,
65        #[serde(default)]
66        pub related_resources: Vec<Resource>,
67        #[serde(skip_serializing_if = "Vec::is_empty", default)]
68        pub tool_invocations: Vec<crate::mcp::ToolInvocationSummary>,
69    }
70
71    #[derive(Debug, Clone, Serialize, Deserialize)]
72    pub struct Suggestion {
73        pub description: String,
74        pub code_example: Option<String>,
75        pub priority: u8,
76    }
77
78    #[derive(Debug, Clone, Serialize, Deserialize)]
79    pub struct Resource {
80        pub title: String,
81        pub url: String,
82        pub source: String,
83    }
84}