Skip to content

Commit

Permalink
Add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Esper89 committed Oct 3, 2024
1 parent 00e1bea commit a599b19
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions astro_modloader/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use log::{Level, LevelFilter, Log, Metadata, Record, SetLoggerError};

#[derive(Debug)]
struct SimpleLogger {
// Synchronize log entries
file: Mutex<BufWriter<fs::File>>,
}

Expand All @@ -18,6 +19,7 @@ impl SimpleLogger {
}

fn lock<T>(&self, f: impl FnOnce(&mut BufWriter<fs::File>) -> T) -> T {
// Ignore log mutex poison
let mut guard = match self.file.lock() {
Ok(guard) => guard,
Err(err) => err.into_inner(),
Expand Down Expand Up @@ -91,6 +93,7 @@ fn get_logger() -> &'static SimpleLogger {
static LOGGER: OnceLock<SimpleLogger> = OnceLock::new();
LOGGER.get_or_init(|| {
SimpleLogger::new(
// Open file
fs::OpenOptions::new()
.write(true)
.create(true)
Expand Down

0 comments on commit a599b19

Please sign in to comment.