Merge pull request #335 from tstenner/env_logger

Update env_logger
This commit is contained in:
Sasha Hilton 2019-06-01 19:45:45 +02:00 committed by GitHub
commit 4e3576ba7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 348 additions and 248 deletions

581
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -34,7 +34,7 @@ path = "protocol"
[dependencies]
base64 = "0.5.0"
env_logger = "0.4.0"
env_logger = "0.6.1"
futures = "0.1.8"
getopts = "0.2.14"
hyper = "0.11.2"

View file

@ -14,7 +14,6 @@ extern crate sha1;
extern crate hex;
use sha1::{Sha1, Digest};
use env_logger::LogBuilder;
use futures::sync::mpsc::UnboundedReceiver;
use futures::{Async, Future, Poll, Stream};
use std::env;
@ -53,11 +52,11 @@ fn usage(program: &str, opts: &getopts::Options) -> String {
}
fn setup_logging(verbose: bool) {
let mut builder = LogBuilder::new();
let mut builder = env_logger::Builder::new();
match env::var("RUST_LOG") {
Ok(config) => {
builder.parse(&config);
builder.init().unwrap();
builder.parse_filters(&config);
builder.init();
if verbose {
warn!("`--verbose` flag overidden by `RUST_LOG` environment variable");
@ -65,11 +64,11 @@ fn setup_logging(verbose: bool) {
}
Err(_) => {
if verbose {
builder.parse("mdns=info,librespot=trace");
builder.parse_filters("mdns=info,librespot=trace");
} else {
builder.parse("mdns=info,librespot=info");
builder.parse_filters("mdns=info,librespot=info");
}
builder.init().unwrap();
builder.init();
}
}
}