pub fn parse_records_from_string(content: &str) -> Vec<Record>Expand description
从字符串解析记录
这是一个便捷函数,将字符串内容解析为 Record 列表。
会自动跳过无效的行,只返回成功解析的记录。
§参数
content- 包含日志内容的字符串
§返回
返回成功解析的 Record 列表
§示例
use dm_database_parser_sqllog::parse_records_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
2025-08-12 10:57:10.000 (EP[0] sess:124 thrd:457 user:bob trxid:790 stmt:1000 appname:app) SELECT 2"#;
let records = parse_records_from_string(log);
assert_eq!(records.len(), 2);