parent
a25eaf1476
commit
43f6565fa5
|
@ -736,7 +736,7 @@ dependencies = [
|
||||||
"hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"image 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"image 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -21,7 +21,7 @@ zip = "0.4.2"
|
||||||
image = "0.7.0"
|
image = "0.7.0"
|
||||||
rand = "0.3.14"
|
rand = "0.3.14"
|
||||||
rustc-serialize = "0.3.24"
|
rustc-serialize = "0.3.24"
|
||||||
log = "0.3.5"
|
log = "0.4.5"
|
||||||
cgmath = "0.7.0"
|
cgmath = "0.7.0"
|
||||||
lazy_static = "0.1.15"
|
lazy_static = "0.1.15"
|
||||||
collision = {git = "https://github.com/TheUnnamedDude/collision-rs", rev = "f80825e"}
|
collision = {git = "https://github.com/TheUnnamedDude/collision-rs", rev = "f80825e"}
|
||||||
|
|
|
@ -273,21 +273,21 @@ impl Console {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log(&mut self, record: &log::LogRecord) {
|
fn log(&mut self, record: &log::Record) {
|
||||||
for filtered in FILTERED_CRATES {
|
for filtered in FILTERED_CRATES {
|
||||||
if record.location().module_path().starts_with(filtered) {
|
if record.module_path().unwrap_or("").starts_with(filtered) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut file = &record.location().file().replace("\\", "/")[..];
|
let mut file = &record.file().unwrap_or("").replace("\\", "/")[..];
|
||||||
if let Some(pos) = file.rfind("src/") {
|
if let Some(pos) = file.rfind("src/") {
|
||||||
file = &file[pos + 4..];
|
file = &file[pos + 4..];
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("[{}:{}][{}] {}",
|
println!("[{}:{}][{}] {}",
|
||||||
file,
|
file,
|
||||||
record.location().line(),
|
record.line().unwrap_or(0),
|
||||||
record.level(),
|
record.level(),
|
||||||
record.args());
|
record.args());
|
||||||
self.history.remove(0);
|
self.history.remove(0);
|
||||||
|
@ -301,7 +301,7 @@ impl Console {
|
||||||
},
|
},
|
||||||
Component::Text(TextComponent::new(":")),
|
Component::Text(TextComponent::new(":")),
|
||||||
{
|
{
|
||||||
let mut msg = TextComponent::new(&format!("{}", record.location().line()));
|
let mut msg = TextComponent::new(&format!("{}", record.line().unwrap_or(0)));
|
||||||
msg.modifier.color = Some(Color::Aqua);
|
msg.modifier.color = Some(Color::Aqua);
|
||||||
Component::Text(msg)
|
Component::Text(msg)
|
||||||
},
|
},
|
||||||
|
@ -310,11 +310,11 @@ impl Console {
|
||||||
{
|
{
|
||||||
let mut msg = TextComponent::new(&format!("{}", record.level()));
|
let mut msg = TextComponent::new(&format!("{}", record.level()));
|
||||||
msg.modifier.color = Some(match record.level() {
|
msg.modifier.color = Some(match record.level() {
|
||||||
log::LogLevel::Debug => Color::Green,
|
log::Level::Debug => Color::Green,
|
||||||
log::LogLevel::Error => Color::Red,
|
log::Level::Error => Color::Red,
|
||||||
log::LogLevel::Warn => Color::Yellow,
|
log::Level::Warn => Color::Yellow,
|
||||||
log::LogLevel::Info => Color::Aqua,
|
log::Level::Info => Color::Aqua,
|
||||||
log::LogLevel::Trace => Color::Blue,
|
log::Level::Trace => Color::Blue,
|
||||||
});
|
});
|
||||||
Component::Text(msg)
|
Component::Text(msg)
|
||||||
},
|
},
|
||||||
|
@ -337,15 +337,18 @@ impl ConsoleProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl log::Log for ConsoleProxy {
|
impl log::Log for ConsoleProxy {
|
||||||
fn enabled(&self, metadata: &log::LogMetadata) -> bool {
|
fn enabled(&self, metadata: &log::Metadata) -> bool {
|
||||||
metadata.level() <= log::LogLevel::Trace
|
metadata.level() <= log::Level::Trace
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log(&self, record: &log::LogRecord) {
|
fn log(&self, record: &log::Record) {
|
||||||
if self.enabled(record.metadata()) {
|
if self.enabled(record.metadata()) {
|
||||||
self.console.lock().unwrap().log(record);
|
self.console.lock().unwrap().log(record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn flush(&self) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for ConsoleProxy {}
|
unsafe impl Send for ConsoleProxy {}
|
||||||
|
|
|
@ -177,10 +177,8 @@ fn main() {
|
||||||
|
|
||||||
let proxy = console::ConsoleProxy::new(con.clone());
|
let proxy = console::ConsoleProxy::new(con.clone());
|
||||||
|
|
||||||
log::set_logger(|max_log_level| {
|
log::set_boxed_logger(Box::new(proxy)).unwrap();
|
||||||
max_log_level.set(log::LogLevelFilter::Trace);
|
log::set_max_level(log::LevelFilter::Trace);
|
||||||
Box::new(proxy)
|
|
||||||
}).unwrap();
|
|
||||||
|
|
||||||
info!("Starting steven");
|
info!("Starting steven");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue