use inklog::{FileSinkConfig, InklogConfig, LoggerManager};
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let encryption_key = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=";
std::env::set_var("INKLOG_ENCRYPTION_KEY", encryption_key);
let log_path: PathBuf = "logs/encrypted.log.enc".into();
std::fs::create_dir_all("logs").ok();
let file_config = FileSinkConfig {
enabled: true,
path: log_path,
max_size: "1MB".into(),
rotation_time: "daily".into(),
keep_files: 5,
compress: false, encrypt: true,
encryption_key_env: Some("INKLOG_ENCRYPTION_KEY".into()),
..Default::default()
};
let config = InklogConfig {
file_sink: Some(file_config),
..Default::default()
};
let _logger = LoggerManager::with_config(config).await?;
log::info!("This message will be encrypted");
log::warn!("Sensitive data is protected at rest");
log::error!("Error details are also encrypted");
println!("\nEncrypted logging example completed!");
println!("Logs are encrypted with AES-256-GCM");
println!("Output file: logs/encrypted.log.enc");
std::env::remove_var("INKLOG_ENCRYPTION_KEY");
Ok(())
}