From 7a7499aeaa45a33aed4b3bfd339c950fa21e1a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 12 Oct 2020 21:04:22 +0200 Subject: change to actual logging (#2) --- mumd/src/main.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'mumd/src/main.rs') 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; -- cgit v1.2.1