aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/main.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-10-12 21:04:22 +0200
committerGitHub <noreply@github.com>2020-10-12 21:04:22 +0200
commit7a7499aeaa45a33aed4b3bfd339c950fa21e1a08 (patch)
tree4cbc408c5813bc37a213cd0476417e7b905fd83e /mumd/src/main.rs
parent2deba9cda37de3fcc04d3ec11ffea0f18a0dbb69 (diff)
downloadmum-7a7499aeaa45a33aed4b3bfd339c950fa21e1a08.tar.gz
change to actual logging (#2)
Diffstat (limited to 'mumd/src/main.rs')
-rw-r--r--mumd/src/main.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/mumd/src/main.rs b/mumd/src/main.rs
index afc1b2e..fcffb87 100644
--- a/mumd/src/main.rs
+++ b/mumd/src/main.rs
@@ -8,9 +8,11 @@ use crate::state::Server;
use argparse::ArgumentParser;
use argparse::Store;
use argparse::StoreTrue;
+use colored::*;
use cpal::traits::StreamTrait;
use futures::channel::oneshot;
use futures::join;
+use log::*;
use mumble_protocol::crypt::ClientCryptState;
use std::net::ToSocketAddrs;
use std::sync::Arc;
@@ -18,6 +20,28 @@ use std::sync::Mutex;
#[tokio::main]
async fn main() {
+ // setup logger
+ fern::Dispatch::new()
+ .format(|out, message, record| {
+ out.finish(format_args!(
+ "{} {}:{} {}",
+ //TODO runtime flag that disables color
+ match record.level() {
+ Level::Error => "ERROR".red(),
+ Level::Warn => "WARN ".yellow(),
+ Level::Info => "INFO ".normal(),
+ Level::Debug => "DEBUG".green(),
+ Level::Trace => "TRACE".normal(),
+ },
+ record.file().unwrap(),
+ record.line().unwrap(),
+ message
+ ))
+ })
+ .level(log::LevelFilter::Debug)
+ .chain(std::io::stderr())
+ .apply().unwrap();
+
// Handle command line arguments
let mut server_host = "".to_string();
let mut server_port = 64738u16;