38 lines
1.0 KiB
Rust
38 lines
1.0 KiB
Rust
![]() |
use dir_odt_to_pdf::error::Result;
|
||
|
use dir_odt_to_pdf::logging::{LogConfig, init_logging};
|
||
|
use log::{LevelFilter, debug, info};
|
||
|
use std::fs;
|
||
|
|
||
|
#[test]
|
||
|
fn test_simple_logging() -> Result<()> {
|
||
|
// Create a temporary file for logging
|
||
|
let temp_dir = tempfile::TempDir::new().unwrap();
|
||
|
let log_path = temp_dir.path().join("test.log");
|
||
|
|
||
|
// 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)?;
|
||
|
|
||
|
// Write some log messages
|
||
|
debug!("This is a debug message");
|
||
|
info!("This is an info message");
|
||
|
|
||
|
// Read the log file
|
||
|
let content = fs::read_to_string(&log_path).unwrap();
|
||
|
println!("=== Log File Contents ===");
|
||
|
println!("{}", content);
|
||
|
println!("=======================");
|
||
|
|
||
|
// Verify log messages
|
||
|
assert!(content.contains("This is a debug message"));
|
||
|
assert!(content.contains("This is an info message"));
|
||
|
|
||
|
Ok(())
|
||
|
}
|