summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-12-16 00:43:08 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-12-17 15:10:46 +0100
commit48fefe07ee4cdc9227893e9e62ceba897fcd3f65 (patch)
tree389c814128395088f3b1551f2c765899cdd72bec /rust
parent6ec284ba70e736bc24523b279303cee46b06071a (diff)
downloadauth-xmppmessage-48fefe07ee4cdc9227893e9e62ceba897fcd3f65.tar.gz
auth-xmppmessage-48fefe07ee4cdc9227893e9e62ceba897fcd3f65.zip
replace env_logger with simple_logger
Diffstat (limited to 'rust')
-rw-r--r--rust/Cargo.toml3
-rw-r--r--rust/src/main.rs8
2 files changed, 7 insertions, 4 deletions
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 <yvesf+git@xapek.org>"]
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<String> = 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<u8> = repeat(0).take((hasher.output_bits() + 7) / 8).collect();
matches.opt_str("s").and_then(|s| {