Further logs improvements
This commit is contained in:
parent
517d66b11b
commit
0b26338659
@ -112,7 +112,16 @@ fn send_clients_name(to: &SocketAddr, lock: &mut MutexGuard<UserMap>) {
|
|||||||
if client == to {
|
if client == to {
|
||||||
let stream = &entry.1;
|
let stream = &entry.1;
|
||||||
let mut writer = BufWriter::new(stream);
|
let mut writer = BufWriter::new(stream);
|
||||||
writeln!(writer, "LIST CLIENTS {}", clients).unwrap();
|
let mut req = String::from("LIST CLIENTS ");
|
||||||
|
req.push_str(clients);
|
||||||
|
println!(
|
||||||
|
"{time} to {nick}@{addr} : {message}",
|
||||||
|
time = get_time(),
|
||||||
|
nick = &entry.0,
|
||||||
|
addr = &entry.1.peer_addr().unwrap(),
|
||||||
|
message = req
|
||||||
|
);
|
||||||
|
writeln!(writer, "{}", req).unwrap();
|
||||||
writer.flush().unwrap();
|
writer.flush().unwrap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -345,10 +354,11 @@ fn handle_client(stream: TcpStream, clients: Arc<Mutex<UserMap>>) {
|
|||||||
match input {
|
match input {
|
||||||
"BYE" => {
|
"BYE" => {
|
||||||
println!(
|
println!(
|
||||||
"{time} to client {addr} : {message}",
|
"{time} to {nick}@{addr} : {message}",
|
||||||
time = get_time(),
|
time = get_time(),
|
||||||
addr = client,
|
addr = client,
|
||||||
message = "BYE"
|
message = "BYE",
|
||||||
|
nick = name
|
||||||
);
|
);
|
||||||
send!("BYE");
|
send!("BYE");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -356,10 +366,11 @@ fn handle_client(stream: TcpStream, clients: Arc<Mutex<UserMap>>) {
|
|||||||
|
|
||||||
"PING" => {
|
"PING" => {
|
||||||
println!(
|
println!(
|
||||||
"{time} to client {addr} : {message}",
|
"{time} to {nick}@{addr} : {message}",
|
||||||
time = get_time(),
|
time = get_time(),
|
||||||
addr = client,
|
addr = client,
|
||||||
message = "NAME FAILURE"
|
message = "NAME FAILURE",
|
||||||
|
nick = name
|
||||||
);
|
);
|
||||||
send!("PONG");
|
send!("PONG");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user