use structured_logging::*;
fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
println!("🚀 Context-Aware Structured Logging Demo for SpinKube");
println!("=====================================================\n");
let config = EnhancedObservabilityConfig::default();
let extension = PerformanceExtension::new(config)?;
println!("✅ Context-aware structured logging initialized");
println!();
println!("🔬 DEMO 1: LLM Operations with Standard Logging");
println!("-----------------------------------------------");
set_llm_context("gpt-4", "llm_client");
log::info!("Request started");
log::info!("Request completed with 250ms duration, 1500 tokens, success status");
log::debug!("Token processing finished with 100 input tokens, 1400 output tokens");
clear_all_contexts();
println!(" ✅ Standard log::info! automatically enhanced with LLM structure");
println!();
println!("🎨 DEMO 2: Template Operations with Standard Logging");
println!("---------------------------------------------------");
set_template_context("Sailfish", "agent_card.stpl", "template_engine");
log::debug!("Template compilation started");
log::info!("Template rendered in 50ms, size 2048 bytes, success");
log::debug!("Template cache updated");
clear_all_contexts();
println!(" ✅ Standard log::info! automatically enhanced with template structure");
println!();
println!("🔗 DEMO 3: A2A Operations with Standard Logging");
println!("----------------------------------------------");
set_a2a_context("chat_completion", "agent-1", "agent-2", "a2a_client");
log::info!("A2A message sent");
log::info!("A2A response received in 100ms, success");
log::debug!("A2A connection established");
clear_all_contexts();
println!(" ✅ Standard log::info! automatically enhanced with A2A structure");
println!();
println!("📊 DEMO 4: Standard Logging Still Works");
println!("---------------------------------------");
log::info!("Agent startup completed");
log::debug!("Configuration loaded from file: config.json");
log::warn!("High memory usage detected: 85%");
log::error!("Connection timeout to external service");
println!(" ✅ Standard logging without context works as expected");
println!();
println!("🎉 Context-aware structured logging demo completed successfully!");
println!();
println!("💡 Key Benefits:");
println!(" ✨ Use standard log::info!, log::debug! macros");
println!(" 🎯 Automatic domain-specific enhancement based on context");
println!(" 🔧 No custom methods to remember");
println!(" 📋 Built on hexagonal architecture foundation");
println!(" âš¡ WASM-compatible and performant");
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_context_aware_demo_components() {
let config = EnhancedObservabilityConfig::default();
let extension = PerformanceExtension::new(config);
assert!(extension.is_ok());
set_llm_context("test-model", "test-component");
clear_all_contexts();
assert!(true);
}
}