i2c: Initialize env_logger

The i2c crate now uses log crate to publish error, info and warn
messages, but doesn't initialize a logger yet and these messages never
make it out.

Initialize the env_logger to see these messages.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
Viresh Kumar 2021-12-23 14:56:19 +05:30
parent faae8d3569
commit 8d8950b4cf
4 changed files with 56 additions and 1 deletions

52
Cargo.lock generated
View File

@ -2,6 +2,15 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
[[package]]
name = "arc-swap"
version = "1.5.0"
@ -70,6 +79,19 @@ dependencies = [
"syn",
]
[[package]]
name = "env_logger"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]]
name = "hashbrown"
version = "0.11.2"
@ -94,6 +116,12 @@ dependencies = [
"libc",
]
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "indexmap"
version = "1.7.0"
@ -131,6 +159,12 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]]
name = "os_str_bytes"
version = "2.4.0"
@ -179,6 +213,23 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "strsim"
version = "0.10.0"
@ -281,6 +332,7 @@ name = "vhost-device-i2c"
version = "0.1.0"
dependencies = [
"clap",
"env_logger",
"libc",
"log",
"thiserror",

View File

@ -1,5 +1,5 @@
{
"coverage_score": 74.1,
"coverage_score": 73.9,
"exclude_path": "",
"crate_features": ""
}

View File

@ -13,6 +13,7 @@ edition = "2018"
[dependencies]
clap = { version = "=3.0.0-beta.2", features = ["yaml"] }
env_logger = ">=0.9"
libc = ">=0.2.95"
log = ">=0.4.6"
thiserror = "1.0"

View File

@ -233,6 +233,8 @@ fn start_backend<D: 'static + I2cDevice + Send + Sync>(config: I2cConfiguration)
}
fn main() -> Result<()> {
env_logger::init();
let yaml = load_yaml!("cli.yaml");
let cmd_args = App::from(yaml).get_matches();