pub struct Sqllog {
pub ts: String,
pub meta: MetaParts,
pub body: String,
pub indicators: Option<IndicatorsParts>,
}Expand description
SQL 日志记录
表示一条完整的 SQL 日志记录,包含时间戳、元数据、SQL 语句体和可选的性能指标。
§示例
use dm_database_parser_sqllog::parse_sqllogs_from_string;
let log = r#"2025-08-12 10:57:09.548 (EP[0] sess:123 thrd:456 user:alice trxid:789 stmt:999 appname:app) SELECT 1"#;
let results = parse_sqllogs_from_string(log);
if let Ok(sqllog) = &results[0] {
assert_eq!(sqllog.ts, "2025-08-12 10:57:09.548");
assert_eq!(sqllog.meta.username, "alice");
assert_eq!(sqllog.body, "SELECT 1");
}Fields§
§ts: String时间戳,格式为 “YYYY-MM-DD HH:MM:SS.mmm”
meta: MetaParts元数据部分,包含会话信息、用户信息等
body: StringSQL 语句体
indicators: Option<IndicatorsParts>可选的性能指标信息
Implementations§
Source§impl Sqllog
impl Sqllog
Sourcepub fn has_indicators(&self) -> bool
pub fn has_indicators(&self) -> bool
Sourcepub fn execute_time(&self) -> Option<f32>
pub fn execute_time(&self) -> Option<f32>
Sourcepub fn execute_id(&self) -> Option<i64>
pub fn execute_id(&self) -> Option<i64>
Trait Implementations§
impl StructuralPartialEq for Sqllog
Auto Trait Implementations§
impl Freeze for Sqllog
impl RefUnwindSafe for Sqllog
impl Send for Sqllog
impl Sync for Sqllog
impl Unpin for Sqllog
impl UnwindSafe for Sqllog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more