summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-09-26 15:06:12 +0200
committertroido <troido@protonmail.com>2020-09-26 15:06:12 +0200
commit5a965b1dd369985698104c7cf99e6a0d10e0ec05 (patch)
tree67746d9a7c97b07545a8b7b3389e9b25a2d5b554
parent9e69a2d3004e83a74cb876ae6c6fbdfb6ed167fb (diff)
include timestamps in logs
-rw-r--r--Cargo.toml1
-rw-r--r--src/gameserver.rs3
-rw-r--r--src/main.rs4
3 files changed, 6 insertions, 2 deletions
diff --git a/Cargo.toml b/Cargo.toml
index db2e00b..86cbcc8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,3 +22,4 @@ base64 = "0.12.0"
ring = "0.16.12"
strum = "0.19"
strum_macros = "0.19"
+chrono = "0.4.17"
diff --git a/src/gameserver.rs b/src/gameserver.rs
index ccb9e30..9ab27c8 100644
--- a/src/gameserver.rs
+++ b/src/gameserver.rs
@@ -6,6 +6,7 @@ use std::io;
use serde_json::{Value, json};
use serde::{Deserialize};
use unicode_categories::UnicodeCategories;
+use chrono::Utc;
use crate::{
controls::{Control, Action},
@@ -102,7 +103,7 @@ impl GameServer {
}
pub fn broadcast_message(&mut self, text: &str){
- println!("m {}", text);
+ println!("m {} {}", text, Utc::now());
self.broadcast_json(json!(["message", text, ""]));
}
diff --git a/src/main.rs b/src/main.rs
index 58faf21..6cd0f24 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,6 +4,7 @@ use std::time::Duration;
use std::path::PathBuf;
use std::sync::{Arc, atomic::{AtomicBool, Ordering}};
use structopt::StructOpt;
+use chrono::Utc;
mod server;
mod gameserver;
@@ -131,7 +132,7 @@ fn main(){
}).expect("can't set close handler");
- println!("asciifarm started");
+ println!("asciifarm started on {}", Utc::now());
while running.load(Ordering::SeqCst) {
@@ -181,6 +182,7 @@ fn main(){
println!("saving world");
world.save();
println!("world saved");
+ println!("shutting down on {}", Utc::now());
}