mirror of
https://github.com/yuhkix/wuwa-downloader.git
synced 2025-06-07 10:13:42 +00:00
18 lines
506 B
Rust
18 lines
506 B
Rust
use std::{fs::{self, OpenOptions}, io::Write, time::SystemTime};
|
|
|
|
|
|
pub fn setup_logging() -> fs::File {
|
|
OpenOptions::new()
|
|
.create(true)
|
|
.append(true)
|
|
.open("logs.log")
|
|
.expect("Failed to create/open log file")
|
|
}
|
|
|
|
pub fn log_error(mut log_file: &fs::File, message: &str) {
|
|
let timestamp = SystemTime::now()
|
|
.duration_since(SystemTime::UNIX_EPOCH)
|
|
.unwrap()
|
|
.as_secs();
|
|
writeln!(log_file, "[{}] ERROR: {}", timestamp, message).unwrap();
|
|
}
|