19 lines
674 B
Rust
19 lines
674 B
Rust
use lazy_static::lazy_static;
|
|
|
|
lazy_static! {
|
|
pub static ref LOG_FILE: Mutex<BufWriter<File>> = {
|
|
// here we would add the code to grab the location of the log file from the config file.
|
|
// for now, im just using "waycrab.log", which would just place the log file next to the executable. probably.
|
|
let writer = BufWriter::new(File::options().append(true).create(true).write(true).open("waycrab.log").unwrap());
|
|
writer.into()
|
|
};
|
|
}
|
|
|
|
use std::{io::{BufWriter, Write}, fs::File, sync::Mutex};
|
|
|
|
pub fn log(entry: &str) {
|
|
let mut log = LOG_FILE.lock().unwrap();
|
|
log.write_all(entry.as_bytes()).unwrap();
|
|
log.flush().unwrap();
|
|
}
|