Replace println! with log crate facade macros info!, debug!, etc.

This commit is contained in:
ice_iix 2019-05-22 16:01:14 -07:00
parent c532c31530
commit bdf18cc6d4
2 changed files with 7 additions and 5 deletions

View File

@ -2,6 +2,7 @@
/// Implements https://wiki.vg/Minecraft_Forge_Handshake /// Implements https://wiki.vg/Minecraft_Forge_Handshake
use std::io; use std::io;
use byteorder::WriteBytesExt; use byteorder::WriteBytesExt;
use log::debug;
use crate::protocol::{Serializable, Error, LenPrefixed, VarInt}; use crate::protocol::{Serializable, Error, LenPrefixed, VarInt};
@ -132,7 +133,7 @@ impl Serializable for FmlHs {
None None
}; };
println!("FML|HS ServerHello: fml_protocol_version={}, override_dimension={:?}", fml_protocol_version, override_dimension); debug!("FML|HS ServerHello: fml_protocol_version={}, override_dimension={:?}", fml_protocol_version, override_dimension);
Ok(FmlHs::ServerHello { Ok(FmlHs::ServerHello {
fml_protocol_version, fml_protocol_version,

View File

@ -38,6 +38,7 @@ use flate2::read::{ZlibDecoder, ZlibEncoder};
use flate2::Compression; use flate2::Compression;
use std::time::{Instant, Duration}; use std::time::{Instant, Duration};
use crate::shared::Position; use crate::shared::Position;
use log::debug;
pub const SUPPORTED_PROTOCOLS: [i32; 14] = [480, 477, 452, 451, 404, 340, 316, 315, 210, 109, 107, 74, 47, 5]; pub const SUPPORTED_PROTOCOLS: [i32; 14] = [480, 477, 452, 451, 404, 340, 316, 315, 210, 109, 107, 74, 47, 5];
@ -1021,7 +1022,7 @@ impl Conn {
write.read_to_end(&mut new)?; write.read_to_end(&mut new)?;
let network_debug = unsafe { NETWORK_DEBUG }; let network_debug = unsafe { NETWORK_DEBUG };
if network_debug { if network_debug {
println!("Compressed for sending {} bytes to {} since > threshold {}, new={:?}", debug!("Compressed for sending {} bytes to {} since > threshold {}, new={:?}",
uncompressed_size, new.len(), self.compression_threshold, uncompressed_size, new.len(), self.compression_threshold,
new); new);
} }
@ -1054,7 +1055,7 @@ impl Conn {
reader.read_to_end(&mut new)?; reader.read_to_end(&mut new)?;
} }
if network_debug { if network_debug {
println!("Decompressed threshold={} len={} uncompressed_size={} to {} bytes", debug!("Decompressed threshold={} len={} uncompressed_size={} to {} bytes",
self.compression_threshold, len, uncompressed_size, new.len()); self.compression_threshold, len, uncompressed_size, new.len());
} }
buf = io::Cursor::new(new); buf = io::Cursor::new(new);
@ -1068,14 +1069,14 @@ impl Conn {
}; };
if network_debug { if network_debug {
println!("about to parse id={:x}, dir={:?} state={:?}", id, dir, self.state); debug!("about to parse id={:x}, dir={:?} state={:?}", id, dir, self.state);
std::fs::File::create("last-packet")?.write_all(buf.get_ref())?; std::fs::File::create("last-packet")?.write_all(buf.get_ref())?;
} }
let packet = packet::packet_by_id(self.protocol_version, self.state, dir, id, &mut buf)?; let packet = packet::packet_by_id(self.protocol_version, self.state, dir, id, &mut buf)?;
if network_debug { if network_debug {
println!("packet = {:?}", packet); debug!("packet = {:?}", packet);
} }
match packet { match packet {