From 3543cc5b5af1d1f1973564ba0d5ea217a2788f61 Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 25 Oct 2020 23:59:50 -0600 Subject: [PATCH] logging in login and ship --- src/bin/login.rs | 23 +++++++++++++++++++++++ src/bin/main.rs | 2 +- src/bin/ship.rs | 23 +++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/bin/login.rs b/src/bin/login.rs index 0ed44e0..7fec40c 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -5,6 +5,29 @@ use elseware::login::character::CharacterServerState; use elseware::common::mainloop::{login_mainloop, character_mainloop}; fn main() { + let colors = fern::colors::ColoredLevelConfig::new() + .error(fern::colors::Color::Red) + .warn(fern::colors::Color::Yellow) + .info(fern::colors::Color::Green) + .debug(fern::colors::Color::White) + .trace(fern::colors::Color::BrightBlack); + let stdio = fern::Dispatch::new() + .level(log::LevelFilter::Debug) + .format(move |out, message, record| { + out.finish(format_args!( + "\x1B[{}m[{}][{}][{}] {}\x1B[0m", + colors.get_color(&record.level()).to_fg_str(), + chrono::Local::now().format("%Y-%m-%d %H:%M:%S"), + record.target(), + record.level(), + message, + )) + }) + .chain(std::io::stdout()); + fern::Dispatch::new() + .chain(stdio) + .apply().unwrap(); + let db_host = std::env::var("DB_HOST").unwrap(); let db_username = std::env::var("DB_USERNAME").unwrap(); let db_password = std::env::var("DB_PASSWORD").unwrap(); diff --git a/src/bin/main.rs b/src/bin/main.rs index a23ff54..0bfbed6 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -54,7 +54,7 @@ fn main() { for i in 0..5 { let fake_user = NewUserAccountEntity { email: format!("fake{}@email.com", i), - username: if i == 0 { "hiz".to_string() } else { format!("hi{}", i+1) }, + username: if i == 0 { "hi".to_string() } else { format!("hi{}", i+1) }, password: bcrypt::hash("qwer", 5).unwrap(), guildcard: i + 1, team_id: None, diff --git a/src/bin/ship.rs b/src/bin/ship.rs index 78cfa5a..304680b 100644 --- a/src/bin/ship.rs +++ b/src/bin/ship.rs @@ -5,6 +5,29 @@ use elseware::ship::ship::ShipServerStateBuilder; use elseware::common::mainloop::ship_mainloop; fn main() { + let colors = fern::colors::ColoredLevelConfig::new() + .error(fern::colors::Color::Red) + .warn(fern::colors::Color::Yellow) + .info(fern::colors::Color::Green) + .debug(fern::colors::Color::White) + .trace(fern::colors::Color::BrightBlack); + let stdio = fern::Dispatch::new() + .level(log::LevelFilter::Debug) + .format(move |out, message, record| { + out.finish(format_args!( + "\x1B[{}m[{}][{}][{}] {}\x1B[0m", + colors.get_color(&record.level()).to_fg_str(), + chrono::Local::now().format("%Y-%m-%d %H:%M:%S"), + record.target(), + record.level(), + message, + )) + }) + .chain(std::io::stdout()); + fern::Dispatch::new() + .chain(stdio) + .apply().unwrap(); + let db_host = std::env::var("DB_HOST").unwrap(); let db_username = std::env::var("DB_USERNAME").unwrap(); let db_password = std::env::var("DB_PASSWORD").unwrap();