smarter log matching

master
Edward Shen 2019-12-23 19:42:30 -05:00
parent b5ef53bc30
commit 5218c8a92d
Signed by: edward
GPG Key ID: F350507060ED6C90
3 changed files with 23 additions and 11 deletions

13
Cargo.lock generated
View File

@ -446,6 +446,7 @@ dependencies = [
"atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1555,11 +1556,22 @@ dependencies = [
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "term_size"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2080,6 +2092,7 @@ dependencies = [
"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
"checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238"
"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
"checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865"

View File

@ -19,7 +19,7 @@ itertools = "0.8"
libc = "0.2"
log = "0.4"
simple_logger = "1.3"
clap = { version = "2.33", features = ["yaml"] }
clap = { version = "2.33", features = ["yaml", "wrap_help"] }
[profile.release]
lto = true

View File

@ -71,16 +71,15 @@ fn main() -> Result<(), BunBunError> {
.author(crate_authors!())
.get_matches();
let log_level = match (
matches.occurrences_of("quiet"),
matches.occurrences_of("verbose"),
) {
(2..=std::u64::MAX, _) => None,
(1, _) => Some(log::Level::Error),
(0, 0) => Some(log::Level::Warn),
(_, 1) => Some(log::Level::Info),
(_, 2) => Some(log::Level::Debug),
(_, 3..=std::u64::MAX) => Some(log::Level::Trace),
let log_level = match (matches.occurrences_of("verbose")
- matches.occurrences_of("quiet")) as i32
{
std::i32::MIN..=-2 => None,
-1 => Some(log::Level::Error),
0 => Some(log::Level::Warn),
1 => Some(log::Level::Info),
2 => Some(log::Level::Debug),
3..=std::i32::MAX => Some(log::Level::Trace),
};
if let Some(level) = log_level {