Skip to content

Commit fd028d4

Browse files
committed
Replace println! with log crate facade macros info!, debug!, etc.
1 parent 8071db6 commit fd028d4

File tree

9 files changed

+37
-33
lines changed

9 files changed

+37
-33
lines changed

blocks/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ macro_rules! define_blocks {
166166
if let Some(blocks_by_data) = VANILLA_ID_MAP.modded.get(name) {
167167
blocks_by_data[data].unwrap_or(Block::Missing{})
168168
} else {
169-
//println!("Modded block not supported yet: {}:{} -> {}", id >> 4, data, name);
169+
//info!("Modded block not supported yet: {}:{} -> {}", id >> 4, data, name);
170170
Block::Missing{}
171171
}
172172
} else {
@@ -415,9 +415,9 @@ macro_rules! define_blocks {
415415
let id = flat_id + offset;
416416
/*
417417
if let Some(vanilla_id) = vanilla_id {
418-
println!("{} block state = {:?} hierarchical {}:{} offset={}", id, block, vanilla_id >> 4, vanilla_id & 0xF, offset);
418+
debug!("{} block state = {:?} hierarchical {}:{} offset={}", id, block, vanilla_id >> 4, vanilla_id & 0xF, offset);
419419
} else {
420-
println!("{} block state = {:?} hierarchical none, offset={}", id, block, offset);
420+
debug!("{} block state = {:?} hierarchical none, offset={}", id, block, offset);
421421
}
422422
*/
423423
if offset as isize > last_offset {
@@ -442,7 +442,7 @@ macro_rules! define_blocks {
442442
if let Some(vanilla_id) = vanilla_id {
443443
/*
444444
if offset.is_none() {
445-
println!("(no flat) block state = {:?} hierarchical {}:{}", block, vanilla_id >> 4, vanilla_id & 0xF);
445+
debug!("(no flat) block state = {:?} hierarchical {}:{}", block, vanilla_id >> 4, vanilla_id & 0xF);
446446
}
447447
*/
448448

src/entity/player.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ impl ecs::System for MovementHandler {
545545
let dt = movement.when_last_jump_pressed.unwrap() - movement.when_last_jump_released.unwrap();
546546
if dt.as_secs() == 0 && dt.subsec_millis() <= crate::settings::DOUBLE_JUMP_MS {
547547
movement.want_to_fly = !movement.want_to_fly;
548-
//println!("double jump! dt={:?} toggle want_to_fly = {}", dt, movement.want_to_fly);
548+
//info!("double jump! dt={:?} toggle want_to_fly = {}", dt, movement.want_to_fly);
549549

550550
if gamemode.can_fly() && !gamemode.always_fly() {
551551
movement.flying = movement.want_to_fly;

src/gl/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::ffi;
1919
use std::mem;
2020
use std::ptr;
2121
use std::ops::{Deref, DerefMut};
22+
use log::{error, info};
2223

2324
/// Inits the gl library. This should be called once a context is ready.
2425
pub fn init(vid: & glutin::WindowedContext<glutin::PossiblyCurrent>) {
@@ -373,7 +374,7 @@ impl Texture {
373374
gl::GetIntegerv(gl::MAX_SAMPLES, &mut result[0]);
374375
let use_samples =
375376
if samples > result[0] {
376-
println!("glTexImage2DMultisample: requested {} samples but GL_MAX_SAMPLES is {}", samples, result[0]);
377+
info!("glTexImage2DMultisample: requested {} samples but GL_MAX_SAMPLES is {}", samples, result[0]);
377378
result[0]
378379
} else {
379380
samples
@@ -848,7 +849,6 @@ pub fn check_framebuffer_status() {
848849
};
849850

850851
if status != gl::FRAMEBUFFER_COMPLETE {
851-
println!("glBindFramebuffer failed, glCheckFrameBufferStatus(GL_FRAMEBUFFER) = {} {}", status, s);
852852
panic!("glBindFramebuffer failed, glCheckFrameBufferStatus(GL_FRAMEBUFFER) = {} {}", status, s);
853853
}
854854
}
@@ -862,7 +862,7 @@ pub fn check_gl_error() {
862862
break
863863
}
864864

865-
println!("glGetError = {}", err);
865+
error!("glGetError = {}", err);
866866
}
867867
}
868868
}

src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#![recursion_limit="300"]
1616

1717
use std::time::{Instant, Duration};
18-
use log::{info, warn};
18+
use log::{info, warn, error};
1919
extern crate steven_shared as shared;
2020

2121
use structopt::StructOpt;
@@ -316,7 +316,7 @@ pub fn main() {
316316

317317
let vsync_changed = *game.vars.get(settings::R_VSYNC);
318318
if vsync != vsync_changed {
319-
println!("Changing vsync currently requires restarting");
319+
error!("Changing vsync currently requires restarting");
320320
break;
321321
// TODO: after https://github.com/tomaka/glutin/issues/693 Allow changing vsync on a Window
322322
//vsync = vsync_changed;

src/protocol/forge.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/// Implements https://wiki.vg/Minecraft_Forge_Handshake
33
use std::io;
44
use byteorder::WriteBytesExt;
5+
use log::debug;
56

67
use crate::protocol::{Serializable, Error, LenPrefixed, VarInt};
78

@@ -132,7 +133,7 @@ impl Serializable for FmlHs {
132133
None
133134
};
134135

135-
println!("FML|HS ServerHello: fml_protocol_version={}, override_dimension={:?}", fml_protocol_version, override_dimension);
136+
debug!("FML|HS ServerHello: fml_protocol_version={}, override_dimension={:?}", fml_protocol_version, override_dimension);
136137

137138
Ok(FmlHs::ServerHello {
138139
fml_protocol_version,

src/protocol/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use flate2::read::{ZlibDecoder, ZlibEncoder};
3838
use flate2::Compression;
3939
use std::time::{Instant, Duration};
4040
use crate::shared::Position;
41+
use log::debug;
4142

4243
pub const SUPPORTED_PROTOCOLS: [i32; 14] = [480, 477, 452, 451, 404, 340, 316, 315, 210, 109, 107, 74, 47, 5];
4344

@@ -1021,7 +1022,7 @@ impl Conn {
10211022
write.read_to_end(&mut new)?;
10221023
let network_debug = unsafe { NETWORK_DEBUG };
10231024
if network_debug {
1024-
println!("Compressed for sending {} bytes to {} since > threshold {}, new={:?}",
1025+
debug!("Compressed for sending {} bytes to {} since > threshold {}, new={:?}",
10251026
uncompressed_size, new.len(), self.compression_threshold,
10261027
new);
10271028
}
@@ -1054,7 +1055,7 @@ impl Conn {
10541055
reader.read_to_end(&mut new)?;
10551056
}
10561057
if network_debug {
1057-
println!("Decompressed threshold={} len={} uncompressed_size={} to {} bytes",
1058+
debug!("Decompressed threshold={} len={} uncompressed_size={} to {} bytes",
10581059
self.compression_threshold, len, uncompressed_size, new.len());
10591060
}
10601061
buf = io::Cursor::new(new);
@@ -1068,14 +1069,14 @@ impl Conn {
10681069
};
10691070

10701071
if network_debug {
1071-
println!("about to parse id={:x}, dir={:?} state={:?}", id, dir, self.state);
1072+
debug!("about to parse id={:x}, dir={:?} state={:?}", id, dir, self.state);
10721073
std::fs::File::create("last-packet")?.write_all(buf.get_ref())?;
10731074
}
10741075

10751076
let packet = packet::packet_by_id(self.protocol_version, self.state, dir, id, &mut buf)?;
10761077

10771078
if network_debug {
1078-
println!("packet = {:?}", packet);
1079+
debug!("packet = {:?}", packet);
10791080
}
10801081

10811082
match packet {

src/render/clouds.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use cgmath::{Point3, Matrix4};
55
use byteorder::{WriteBytesExt, NativeEndian};
66
use crate::gl;
77
use super::glsl;
8+
use log::error;
89

910
pub struct Clouds {
1011
program: gl::Program,
@@ -47,13 +48,13 @@ impl Clouds {
4748
v.compile();
4849

4950
if v.get_parameter(gl::COMPILE_STATUS) == 0 {
50-
println!("Src: {}", vertex);
51+
error!("Src: {}", vertex);
5152
panic!("Shader error: {}", v.get_info_log());
5253
} else {
5354
let log = v.get_info_log();
5455
let log = log.trim().trim_matches('\u{0}');
5556
if !log.is_empty() {
56-
println!("{}", log);
57+
error!("{}", log);
5758
}
5859
}
5960

@@ -62,13 +63,13 @@ impl Clouds {
6263
g.compile();
6364

6465
if g.get_parameter(gl::COMPILE_STATUS) == 0 {
65-
println!("Src: {}", geo);
66+
error!("Src: {}", geo);
6667
panic!("Shader error: {}", g.get_info_log());
6768
} else {
6869
let log = g.get_info_log();
6970
let log = log.trim().trim_matches('\u{0}');
7071
if !log.is_empty() {
71-
println!("{}", log);
72+
error!("{}", log);
7273
}
7374
}
7475

@@ -77,13 +78,13 @@ impl Clouds {
7778
f.compile();
7879

7980
if f.get_parameter(gl::COMPILE_STATUS) == 0 {
80-
println!("Src: {}", fragment);
81+
error!("Src: {}", fragment);
8182
panic!("Shader error: {}", f.get_info_log());
8283
} else {
8384
let log = f.get_info_log();
8485
let log = log.trim().trim_matches('\u{0}');
8586
if !log.is_empty() {
86-
println!("{}", log);
87+
error!("{}", log);
8788
}
8889
}
8990

src/render/shaders.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use crate::render::glsl;
1616
use crate::gl;
17+
use log::error;
1718

1819
pub fn add_shaders(reg: &mut glsl::Registry) {
1920
reg.register("lookup_texture", include_str!("shaders/lookup_texture.glsl"));
@@ -128,13 +129,13 @@ pub fn create_program(vertex: &str, fragment: &str) -> gl::Program {
128129
v.compile();
129130

130131
if v.get_parameter(gl::COMPILE_STATUS) == 0 {
131-
println!("Src: {}", vertex);
132+
error!("Src: {}", vertex);
132133
panic!("Shader error: {}", v.get_info_log());
133134
} else {
134135
let log = v.get_info_log();
135136
let log = log.trim().trim_matches('\u{0}');
136137
if !log.is_empty() {
137-
println!("{}", log);
138+
error!("{}", log);
138139
}
139140
}
140141

@@ -143,13 +144,13 @@ pub fn create_program(vertex: &str, fragment: &str) -> gl::Program {
143144
f.compile();
144145

145146
if f.get_parameter(gl::COMPILE_STATUS) == 0 {
146-
println!("Src: {}", fragment);
147+
error!("Src: {}", fragment);
147148
panic!("Shader error: {}", f.get_info_log());
148149
} else {
149150
let log = f.get_info_log();
150151
let log = log.trim().trim_matches('\u{0}');
151152
if !log.is_empty() {
152-
println!("{}", log);
153+
error!("{}", log);
153154
}
154155
}
155156

src/server/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -684,21 +684,21 @@ impl Server {
684684

685685
fn on_plugin_message_clientbound(&mut self, channel: &str, data: &[u8]) {
686686
if unsafe { protocol::NETWORK_DEBUG } {
687-
println!("Received plugin message: channel={}, data={:?}", channel, data);
687+
debug!("Received plugin message: channel={}, data={:?}", channel, data);
688688
}
689689

690690
match channel {
691691
// TODO: "REGISTER" =>
692692
// TODO: "UNREGISTER" =>
693693
"FML|HS" => {
694694
let msg = crate::protocol::Serializable::read_from(&mut std::io::Cursor::new(data)).unwrap();
695-
println!("FML|HS msg={:?}", msg);
695+
//debug!("FML|HS msg={:?}", msg);
696696

697697
use forge::FmlHs::*;
698698
use forge::Phase::*;
699699
match msg {
700700
ServerHello { fml_protocol_version, override_dimension } => {
701-
println!("Received FML|HS ServerHello {} {:?}", fml_protocol_version, override_dimension);
701+
debug!("Received FML|HS ServerHello {} {:?}", fml_protocol_version, override_dimension);
702702

703703
self.write_plugin_message("REGISTER", "FML|HS\0FML\0FML|MP\0FML\0FORGE".as_bytes());
704704
self.write_fmlhs_plugin_message(&ClientHello { fml_protocol_version });
@@ -707,12 +707,12 @@ impl Server {
707707
self.write_fmlhs_plugin_message(&ModList { mods });
708708
},
709709
ModList { mods } => {
710-
println!("Received FML|HS ModList: {:?}", mods);
710+
debug!("Received FML|HS ModList: {:?}", mods);
711711

712712
self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerData });
713713
},
714714
ModIdData { mappings, block_substitutions: _, item_substitutions: _ } => {
715-
println!("Received FML|HS ModIdData");
715+
debug!("Received FML|HS ModIdData");
716716
for m in mappings.data {
717717
let (namespace, name) = m.name.split_at(1);
718718
if namespace == protocol::forge::BLOCK_NAMESPACE {
@@ -722,7 +722,7 @@ impl Server {
722722
self.write_fmlhs_plugin_message(&HandshakeAck { phase: WaitingServerComplete });
723723
},
724724
RegistryData { has_more, name, ids, substitutions: _, dummies: _ } => {
725-
println!("Received FML|HS RegistryData for {}", name);
725+
debug!("Received FML|HS RegistryData for {}", name);
726726
if name == "minecraft:blocks" {
727727
for m in ids.data {
728728
self.world.modded_block_ids.insert(m.id.0 as usize, m.name);
@@ -738,7 +738,7 @@ impl Server {
738738
self.write_fmlhs_plugin_message(&HandshakeAck { phase: PendingComplete });
739739
},
740740
Complete => {
741-
println!("FML|HS handshake complete!");
741+
debug!("FML|HS handshake complete!");
742742
},
743743
_ => unimplemented!(),
744744
}
@@ -761,7 +761,7 @@ impl Server {
761761

762762
fn write_plugin_message(&mut self, channel: &str, data: &[u8]) {
763763
if unsafe { protocol::NETWORK_DEBUG } {
764-
println!("Sending plugin message: channel={}, data={:?}", channel, data);
764+
debug!("Sending plugin message: channel={}, data={:?}", channel, data);
765765
}
766766
if self.protocol_version >= 47 {
767767
self.write_packet(packet::play::serverbound::PluginMessageServerbound {

0 commit comments

Comments
 (0)