Browse Source

logging in login and ship

pbs
jake 4 years ago
parent
commit
3543cc5b5a
  1. 23
      src/bin/login.rs
  2. 2
      src/bin/main.rs
  3. 23
      src/bin/ship.rs

23
src/bin/login.rs

@ -5,6 +5,29 @@ use elseware::login::character::CharacterServerState;
use elseware::common::mainloop::{login_mainloop, character_mainloop}; use elseware::common::mainloop::{login_mainloop, character_mainloop};
fn main() { 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_host = std::env::var("DB_HOST").unwrap();
let db_username = std::env::var("DB_USERNAME").unwrap(); let db_username = std::env::var("DB_USERNAME").unwrap();
let db_password = std::env::var("DB_PASSWORD").unwrap(); let db_password = std::env::var("DB_PASSWORD").unwrap();

2
src/bin/main.rs

@ -54,7 +54,7 @@ fn main() {
for i in 0..5 { for i in 0..5 {
let fake_user = NewUserAccountEntity { let fake_user = NewUserAccountEntity {
email: format!("fake{}@email.com", i), 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(), password: bcrypt::hash("qwer", 5).unwrap(),
guildcard: i + 1, guildcard: i + 1,
team_id: None, team_id: None,

23
src/bin/ship.rs

@ -5,6 +5,29 @@ use elseware::ship::ship::ShipServerStateBuilder;
use elseware::common::mainloop::ship_mainloop; use elseware::common::mainloop::ship_mainloop;
fn main() { 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_host = std::env::var("DB_HOST").unwrap();
let db_username = std::env::var("DB_USERNAME").unwrap(); let db_username = std::env::var("DB_USERNAME").unwrap();
let db_password = std::env::var("DB_PASSWORD").unwrap(); let db_password = std::env::var("DB_PASSWORD").unwrap();

Loading…
Cancel
Save