forked from thoughtpolice/bcachefs-tools
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of the custom logger impl, which limits the features we can easily provide for users. This introduces the `BCACHEFS_LOG` environment variable for setting the log verbosity. Setting `BCACHEFS_LOG=trace`, e.g. in a test environment, will yield all log messages. Also I think it's reasonable to print INFO level logs by default. Signed-off-by: Thomas Mühlbacher <[email protected]>
- Loading branch information
1 parent
411df4e
commit c0d84a1
Showing
8 changed files
with
99 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use env_logger::WriteStyle; | ||
use log::LevelFilter; | ||
|
||
pub fn setup(quiet: bool, verbose: u8, color: bool) { | ||
let level_filter = if quiet { | ||
LevelFilter::Off | ||
} else { | ||
match verbose { | ||
0 => LevelFilter::Info, | ||
1 => LevelFilter::Debug, | ||
_ => LevelFilter::Trace, | ||
} | ||
}; | ||
|
||
let style = if color { | ||
WriteStyle::Always | ||
} else { | ||
WriteStyle::Never | ||
}; | ||
|
||
env_logger::Builder::new() | ||
.filter_level(level_filter) | ||
.write_style(style) | ||
.parse_env("BCACHEFS_LOG") | ||
.init(); | ||
} |