-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
34 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ struct Opt { | |
} | ||
|
||
fn main() -> MainResult { | ||
init_builtin_logger(); | ||
let Opt { | ||
block_size, | ||
thread_num, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,11 @@ | ||
use log::{Level, LevelFilter, Metadata, Record}; | ||
|
||
static LOGGER: CmdLogger = CmdLogger; | ||
|
||
/// Initializes the builtin cmd_lib logger | ||
/// | ||
/// This is to make examples in this library work, and users should usually use a real logger | ||
/// instead. When being used, it should be called early in the main() function. Default log level | ||
/// is set to `debug`. | ||
/// | ||
/// # Panics | ||
/// | ||
/// This function will panic if it is called more than once, or if another | ||
/// library has already initialized a global logger. | ||
pub fn init_builtin_logger() { | ||
log::set_logger(&LOGGER) | ||
.map(|()| log::set_max_level(LevelFilter::Debug)) | ||
.unwrap(); | ||
use log::SetLoggerError; | ||
|
||
#[doc(hidden)] | ||
pub fn try_init_default_logger() -> Result<(), SetLoggerError> { | ||
env_logger::builder() | ||
.filter_level(log::LevelFilter::Info) | ||
.format_target(false) | ||
.format_timestamp(None) | ||
.try_init() | ||
} | ||
|
||
struct CmdLogger; | ||
impl log::Log for CmdLogger { | ||
fn enabled(&self, metadata: &Metadata) -> bool { | ||
metadata.level() <= Level::Debug | ||
} | ||
|
||
fn log(&self, record: &Record) { | ||
if self.enabled(record.metadata()) { | ||
eprintln!("{} - {}", record.level(), record.args()); | ||
} | ||
} | ||
|
||
fn flush(&self) {} | ||
} |