ffdash/engine/core/log.rs
1use anyhow::Result;
2use chrono::Local;
3use std::io::Write;
4
5/// Write debug log to ffdash.log in current directory
6/// Appends to file, creating it if needed
7pub fn write_debug_log(message: &str) -> Result<()> {
8 use std::fs::OpenOptions;
9
10 let log_path = std::env::current_dir()?.join("ffdash.log");
11 let mut file = OpenOptions::new()
12 .create(true)
13 .append(true)
14 .open(log_path)?;
15
16 let timestamp = Local::now().format("%Y-%m-%d %H:%M:%S");
17 writeln!(file, "[{}] {}", timestamp, message)?;
18 Ok(())
19}