Jamie Pine e5c87ffda5 refactor: optimize entry filtering in database queries
- Replaced complex subquery logic with raw SQL for filtering entries based on device ownership, improving query performance and readability.
- Enhanced error handling for UUID synchronization to ensure data consistency.
- Streamlined code by consolidating delete and count operations in the entry closure rebuild process.
- Improved logging in the backfill manager to provide better insights into state changes and record processing.
2025-11-16 11:58:13 -08:00

52 lines
1.8 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! Simple example of using the log analyzer library.
use anyhow::Result;
use log_analyzer::LogAnalyzer;
fn main() -> Result<()> {
// Example log content
let log_content = r#"
2025-11-16T07:19:57.232531Z DEBUG ThreadId(02) sd_core::service::sync::peer: Recorded ACK from peer peer=1817e146 hlc=HLC(1763277539319,1,:1817e146)
2025-11-16T07:19:57.232532Z DEBUG ThreadId(02) sd_core::service::sync::peer: Recorded ACK from peer peer=1817e146 hlc=HLC(1763277539319,2,:1817e146)
2025-11-16T07:19:57.232533Z DEBUG ThreadId(02) sd_core::service::sync::peer: Recorded ACK from peer peer=1817e146 hlc=HLC(1763277539320,1,:1817e146)
2025-11-16T07:19:57.232534Z INFO sd_core::service::sync: Sync completed successfully
2025-11-16T07:19:57.232535Z DEBUG ThreadId(03) sd_core::service::sync::protocol_handler: Handling shared change content_identity
2025-11-16T07:19:57.232536Z DEBUG ThreadId(03) sd_core::service::sync::protocol_handler: Handling shared change content_identity
"#;
// Parse and analyze
let analyzer = LogAnalyzer::from_string(log_content)?;
println!("Analysis Results:");
println!(" Total logs: {}", analyzer.log_count());
println!(" Templates: {}", analyzer.template_count());
println!(" Groups: {}", analyzer.group_count());
println!(
" Compression: {:.1}%",
analyzer.compression_ratio() * 100.0
);
println!("\nTemplates:");
for template in analyzer.templates() {
println!(
" #{}: {} ({}×)",
template.id, template.example, template.total_count
);
}
println!("\nGroups:");
for group in analyzer.groups() {
println!(
" Template #{}: {} instances, {}ms duration",
group.template_id, group.count, group.duration_ms
);
}
// Generate markdown report
let report = analyzer.generate_markdown_report()?;
println!("\n--- Markdown Report ---\n{}", report);
Ok(())
}