Updated simplelogger

This commit is contained in:
Antoine Gersant 2019-09-28 16:54:37 -07:00
parent b89ae5a133
commit 22ae33f029
3 changed files with 14 additions and 19 deletions

6
Cargo.lock generated
View file

@ -1506,7 +1506,7 @@ dependencies = [
"serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
"simplelog 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "simplelog 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unix-daemonize 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "unix-daemonize 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2107,7 +2107,7 @@ dependencies = [
[[package]] [[package]]
name = "simplelog" name = "simplelog"
version = "0.6.0" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2881,7 +2881,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" "checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a"
"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d"
"checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" "checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c"
"checksum simplelog 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9c948a5a26cd38340ddbeaa557a8c8a5ce4442408eb60453bee2bb3c84a3fb" "checksum simplelog 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2b6e1abbebfa1e8e010dd97fae39622173374ec93ff0e05b88123f7d927514b6"
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7"
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"

View file

@ -34,7 +34,7 @@ rust-crypto = "0.2.36"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0" serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
simplelog = "0.6" simplelog = "0.7"
toml = "0.5" toml = "0.5"
[dependencies.rocket_contrib] [dependencies.rocket_contrib]

View file

@ -7,7 +7,8 @@ extern crate diesel;
#[macro_use] #[macro_use]
extern crate diesel_migrations; extern crate diesel_migrations;
#[cfg(feature = "profile-index")] #[cfg(feature = "profile-index")]
#[macro_use] extern crate flamer; #[macro_use]
extern crate flamer;
#[cfg(unix)] #[cfg(unix)]
use libsystemd::daemon::{self, NotifyState}; use libsystemd::daemon::{self, NotifyState};
@ -25,7 +26,7 @@ use core::ops::Deref;
use error_chain::bail; use error_chain::bail;
use getopts::Options; use getopts::Options;
use log::info; use log::info;
use simplelog::{Level, LevelFilter, SimpleLogger, TermLogger, TerminalMode}; use simplelog::{LevelFilter, SimpleLogger, TermLogger, TerminalMode};
use std::path::Path; use std::path::Path;
use std::sync::Arc; use std::sync::Arc;
@ -53,13 +54,9 @@ mod vfs;
mod web; mod web;
fn log_config() -> simplelog::Config { fn log_config() -> simplelog::Config {
simplelog::Config { simplelog::ConfigBuilder::new()
time: Some(Level::Error), .set_location_level(LevelFilter::Error)
level: Some(Level::Error), .build()
target: Some(Level::Error),
location: Some(Level::Error),
..Default::default()
}
} }
fn main() { fn main() {
@ -96,16 +93,15 @@ fn daemonize(options: &getopts::Matches) -> Result<()> {
#[cfg(unix)] #[cfg(unix)]
fn init_log(log_level: LevelFilter, options: &getopts::Matches) -> Result<()> { fn init_log(log_level: LevelFilter, options: &getopts::Matches) -> Result<()> {
let config = log_config();
if options.opt_present("f") { if options.opt_present("f") {
if let Err(e) = TermLogger::init(log_level, config, TerminalMode::Stdout) { if let Err(e) = TermLogger::init(log_level, log_config(), TerminalMode::Stdout) {
println!("Error starting terminal logger: {}", e); println!("Error starting terminal logger: {}", e);
} else { } else {
return Ok(()); return Ok(());
} }
} }
if let Err(e) = SimpleLogger::init(log_level, config) { if let Err(e) = SimpleLogger::init(log_level, log_config()) {
bail!("Error starting simple logger: {}", e); bail!("Error starting simple logger: {}", e);
} }
Ok(()) Ok(())
@ -113,9 +109,8 @@ fn init_log(log_level: LevelFilter, options: &getopts::Matches) -> Result<()> {
#[cfg(windows)] #[cfg(windows)]
fn init_log(log_level: LevelFilter, _: &getopts::Matches) -> Result<()> { fn init_log(log_level: LevelFilter, _: &getopts::Matches) -> Result<()> {
let config = log_config(); if TermLogger::init(log_level, log_config(), TerminalMode::Stdout).is_err() {
if TermLogger::init(log_level, config, TerminalMode::Stdout).is_err() { if let Err(e) = SimpleLogger::init(log_level, log_config()) {
if let Err(e) = SimpleLogger::init(log_level, config) {
bail!("Error starting simple logger: {}", e); bail!("Error starting simple logger: {}", e);
} }
}; };