Remove fern-based logging as it was never that useful due to the inability to set per-crate log levels

This commit is contained in:
Ted Mielczarek 2018-02-01 11:06:25 -05:00
Родитель 79b92a7e3f
Коммит 22e588b87c
4 изменённых файлов: 6 добавлений и 47 удалений

10
Cargo.lock сгенерированный
Просмотреть файл

@ -299,14 +299,6 @@ dependencies = [
"backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "fern"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "filetime" name = "filetime"
version = "0.1.15" version = "0.1.15"
@ -982,7 +974,6 @@ dependencies = [
"daemonize 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "daemonize 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fern 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1609,7 +1600,6 @@ dependencies = [
"checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b"
"checksum environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4b14e20978669064c33b4c1e0fb4083412e40fe56cbea2eae80fd7591503ee" "checksum environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4b14e20978669064c33b4c1e0fb4083412e40fe56cbea2eae80fd7591503ee"
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
"checksum fern 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4d2f58d053ad7791bfaad58a3f3541fe2d2aecc564dd82aee7f92fa402c054b2"
"checksum filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "714653f3e34871534de23771ac7b26e999651a0a228f47beb324dfdf1dd4b10f" "checksum filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "714653f3e34871534de23771ac7b26e999651a0a228f47beb324dfdf1dd4b10f"
"checksum flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423" "checksum flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423"
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"

Просмотреть файл

@ -22,7 +22,6 @@ chrono = { version = "0.3", optional = true }
clap = "2.23.0" clap = "2.23.0"
env_logger = "0.4" env_logger = "0.4"
error-chain = { version = "0.11", default-features = false } error-chain = { version = "0.11", default-features = false }
fern = "0.3.5"
filetime = "0.1" filetime = "0.1"
futures = "0.1.11" futures = "0.1.11"
futures-cpupool = "0.1" futures-cpupool = "0.1"

Просмотреть файл

@ -89,11 +89,9 @@ By default, SCCACHE on GCS will be read-only. To change this, set `SCCACHE_GCS_R
Debugging Debugging
--------- ---------
You can set the `SCCACHE_LOG_LEVEL` environment variable to `debug` or `trace` (not recommended, it's *very verbose*) to cause sccache to output more fine grained logging about what it is doing. A log file named `sccache.log` will be output in the current working directory whenever sccache is invoked. You can run the server manually in foreground mode by running `SCCACHE_START_SERVER=1 SCCACHE_NO_DAEMON=1 sccache`, and send logging to stderr by setting the `RUST_LOG` environment variable, the format of which is described in more detail in the [env_logger](https://docs.rs/env_logger/0.5.3/env_logger/#enabling-logging) documentation.
Alternately, you can run the server manually in foreground mode by running `SCCACHE_START_SERVER=1 SCCACHE_NO_DAEMON=1 sccache`, and send logging to stderr by setting the `RUST_LOG` environment variable, the format of which is described in more detail in the [env_logger](http://burntsushi.net/rustdoc/env_logger/index.html#enabling-logging) documentation. Alternately, you can set the `SCCACHE_ERROR_LOG` environment variable to a path and set `RUST_LOG` to get the server process to redirect its logging there (including the output of unhandled panics, since the server sets `RUST_BACKTRACE=1` internally).
You can set the `SCCACHE_ERROR_LOG` environment variable to a path to cause the server process to redirect its standard error output there, in order to capture the output of unhandled panics. (The server sets `RUST_BACKTRACE=1` internally.)
--- ---

Просмотреть файл

@ -47,7 +47,6 @@ extern crate local_encoding;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate lru_disk_cache; extern crate lru_disk_cache;
extern crate fern;
#[cfg(test)] #[cfg(test)]
extern crate itertools; extern crate itertools;
extern crate libc; extern crate libc;
@ -136,37 +135,10 @@ fn main() {
} }
fn init_logging() { fn init_logging() {
match if env::var("RUST_LOG").is_ok() { if env::var("RUST_LOG").is_ok() {
env_logger::init() match env_logger::init() {
.map_err(|e| format!("{:?}", e)) Ok(_) => (),
} else { Err(e) => panic!(format!("Failed to initalize logging: {:?}", e)),
match env::var("SCCACHE_LOG_LEVEL") {
Ok(log_level) => {
let log_level = match &*log_level.to_lowercase() {
"off" => log::LogLevelFilter::Off,
"trace" => log::LogLevelFilter::Trace,
"debug" => log::LogLevelFilter::Debug,
"info" => log::LogLevelFilter::Info,
"warn" => log::LogLevelFilter::Warn,
"error" => log::LogLevelFilter::Error,
_ => panic!("Invalid log level {}", log_level),
};
let logger_config = fern::DispatchConfig {
format: Box::new(|msg: &str, level: &log::LogLevel, _location: &log::LogLocation| {
format!("[{}][{}] {}", time::now().strftime("%Y-%m-%d][%H:%M:%S").unwrap(), level, msg)
}),
//TODO: only the server process should output to the log file.
output: vec![fern::OutputConfig::stdout(), fern::OutputConfig::file("sccache.log")],
level: log::LogLevelFilter::Trace,
};
fern::init_global_logger(logger_config, log_level)
.map_err(|e| format!("{:?}", e))
},
Err(_) => Ok(()),
} }
} {
Ok(_) => (),
Err(e) => panic!(format!("Failed to initalize logging: {}", e)),
} }
} }