From 48fefe07ee4cdc9227893e9e62ceba897fcd3f65 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Fri, 16 Dec 2016 00:43:08 +0100 Subject: replace env_logger with simple_logger --- rust/Cargo.toml | 3 ++- rust/src/main.rs | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'rust') diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 66f35ae..5b183c4 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -5,13 +5,14 @@ authors = ["Yves Fischer "] build = "build.rs" [dependencies] +ascii = "0.7" tiny_http = "0.5" rustc-serialize = "0.3" time = "0.1" rust-crypto = "0.2" rand = "0.3" getopts = "0.2" -env_logger = "0.3" +simple_logger = "0.4" log = "0.3" [build-dependencies] diff --git a/rust/src/main.rs b/rust/src/main.rs index 7a05c8b..22b1592 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -5,18 +5,19 @@ use std::thread; extern crate ascii; extern crate crypto; -extern crate env_logger; extern crate getopts; #[macro_use] extern crate log; extern crate tiny_http; extern crate time; extern crate rand; extern crate rustc_serialize; +extern crate simple_logger; use crypto::digest::Digest; use crypto::sha1::Sha1; use getopts::Options; use rand::{thread_rng, Rng}; +use log::LogLevel; mod apachelog; mod handler; @@ -30,8 +31,6 @@ fn print_usage(program: &str, opts: Options) { } fn main() { - env_logger::init().unwrap(); - let args: Vec = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); @@ -40,6 +39,7 @@ fn main() { opts.optopt("s", "secret", "server secret for token generation", "SECRET"); opts.optopt("t", "time", "Validity of the token in hours (default 48)", "HOURS"); opts.optopt("o", "port", "TCP Port to listen on", "PORT"); + opts.optflag("d", "debug", "Use loglevel Debug instead of Warn"); opts.optflag("n", "nosend", "Don't send XMPP message, just print debug infos"); opts.optflag("h", "help", "print this help menu"); let matches = opts.parse(&args[1..]).unwrap_or_else(|f| panic!(f.to_string())); @@ -54,6 +54,8 @@ fn main() { panic!("Missing jid or password"); } + simple_logger::init_with_level(if matches.opt_present("d") { LogLevel::Debug } else { LogLevel::Warn }).unwrap(); + let mut hasher = Sha1::new(); let mut secret: Vec = repeat(0).take((hasher.output_bits() + 7) / 8).collect(); matches.opt_str("s").and_then(|s| { -- cgit v1.2.1