40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
![]() |
use dir_odt_to_pdf::error::{ProcessError, Result};
|
||
|
use dir_odt_to_pdf::log_detail;
|
||
|
use dir_odt_to_pdf::logging::{LogConfig, init_logging};
|
||
|
use log::{Level, LevelFilter, debug, info};
|
||
|
use std::fs;
|
||
|
mod common;
|
||
|
|
||
|
#[test]
|
||
|
fn test_log_detail_macro() -> Result<()> {
|
||
|
// Create a temporary file for logging
|
||
|
let (_temp_dir, log_path) = common::setup_test_log_file();
|
||
|
|
||
|
// Initialize logging with Debug level
|
||
|
let config = LogConfig {
|
||
|
log_file: Some(log_path.clone()),
|
||
|
log_level: LevelFilter::Debug,
|
||
|
append_log: false,
|
||
|
};
|
||
|
|
||
|
// Initialize logging
|
||
|
init_logging(config)?;
|
||
|
debug!("Starting test_log_detail_macro test");
|
||
|
|
||
|
// Test the macro
|
||
|
info!("Testing log_detail macro...");
|
||
|
log_detail!(Level::Info, "test detail 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!("=======================");
|
||
|
|
||
|
assert!(content.contains("test detail message"));
|
||
|
assert!(content.contains(file!()));
|
||
|
debug!("Test completed successfully");
|
||
|
|
||
|
Ok(())
|
||
|
}
|