2025-05-27 09:57:16 +01:00
|
|
|
#![cfg(feature = "test-sync")]
|
2025-05-27 00:59:44 +01:00
|
|
|
use dir_odt_to_pdf::error::{ProcessError, Result};
|
|
|
|
use dir_odt_to_pdf::logging::{LogConfig, init_logging};
|
|
|
|
use log::{LevelFilter, debug, error, info, trace, warn};
|
|
|
|
use std::fs;
|
|
|
|
mod common;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_different_log_levels() -> Result<()> {
|
|
|
|
// Create a temporary file for logging
|
|
|
|
let (_temp_dir, log_path) = common::setup_test_log_file();
|
|
|
|
|
|
|
|
// Initialize logging with Trace level
|
|
|
|
let config = LogConfig {
|
|
|
|
log_file: Some(log_path.clone()),
|
|
|
|
log_level: LevelFilter::Trace,
|
|
|
|
append_log: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Initialize logging
|
|
|
|
init_logging(config)?;
|
|
|
|
debug!("Starting test_different_log_levels test");
|
|
|
|
|
|
|
|
// Test all log levels
|
|
|
|
info!("Testing different log levels...");
|
|
|
|
trace!("trace message");
|
|
|
|
debug!("debug message");
|
|
|
|
info!("info message");
|
|
|
|
warn!("warn message");
|
|
|
|
error!("error message");
|
|
|
|
|
|
|
|
// Read and verify the log file
|
|
|
|
let content = fs::read_to_string(&log_path).map_err(ProcessError::Io)?;
|
|
|
|
println!("=== Log File Contents ===");
|
|
|
|
println!("{}", content);
|
|
|
|
println!("=======================");
|
|
|
|
|
|
|
|
// Verify all messages are present
|
|
|
|
assert!(content.contains("trace message"));
|
|
|
|
assert!(content.contains("debug message"));
|
|
|
|
assert!(content.contains("info message"));
|
|
|
|
assert!(content.contains("warn message"));
|
|
|
|
assert!(content.contains("error message"));
|
|
|
|
debug!("Test completed successfully");
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|