basic logging support
This commit is contained in:
parent
fb7aa45e87
commit
1afca4cd38
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"rust-analyzer.linkedProjects": [
|
||||
"./Cargo.toml"
|
||||
],
|
||||
"rust-analyzer.showUnlinkedFileNotification": false
|
||||
}
|
1624
Cargo.lock
generated
Normal file
1624
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -7,3 +7,4 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
smithay = "0.3.0"
|
||||
lazy_static = "1.4.0"
|
16
src/backend/logger.rs
Normal file
16
src/backend/logger.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
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();
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
pub mod logger;
|
|
@ -1,3 +1,9 @@
|
|||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
mod backend;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
backend::logger::log("Hello, world!");
|
||||
}
|
||||
|
|
1
waycrab.log
Normal file
1
waycrab.log
Normal file
|
@ -0,0 +1 @@
|
|||
Hello, world!
|
Loading…
Reference in a new issue