-q, --quiet Set verbosity
--log-file <PATH> Log to the specified file instead of stderr
- --no-buffering Flush log records to the file immediatly
+ --no-buffering Flush log records to the file immediately
ENVIRONMENTAL VARIABLES:
RA_LOG Set log filter in env_logger format
//! filter syntax. Amusingly, there's no crates.io crate that can do this and
//! only this.
-use std::{borrow::BorrowMut, fs::File, io::{BufWriter, Write}};
+use std::{
+ fs::File,
+ io::{self, BufWriter, Write},
+};
use env_logger::filter::{Builder, Filter};
use log::{Log, Metadata, Record};
record.module_path().unwrap_or_default(),
record.args(),
);
-
- if self.no_buffering {
- w.lock().borrow_mut().flush().unwrap();
- }
}
None => eprintln!(
"[{} {}] {}",
record.args(),
),
}
+
+ if self.no_buffering {
+ self.flush();
+ }
}
fn flush(&self) {
- if let Some(w) = &self.file {
- let _ = w.lock().flush();
+ match &self.file {
+ Some(w) => {
+ let _ = w.lock().flush();
+ }
+ None => {
+ let _ = io::stderr().flush();
+ }
}
}
}