1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

Implement a logger so we can get logging output.

This commit is contained in:
Ryan Dahl 2018-07-26 17:37:09 -04:00
parent 57c52a83a0
commit e7445507aa
2 changed files with 21 additions and 2 deletions

View file

@ -67,7 +67,7 @@ fn resolve_module(
module_specifier: &String,
containing_file: &String,
) -> Result<(String, String), url::ParseError> {
info!(
debug!(
"resolve_module before module_specifier {} containing_file {}",
module_specifier, containing_file
);

View file

@ -136,8 +136,27 @@ fn test_parse_core_args_2() {
assert!(js_args == (vec!["deno".to_string()], vec!["--help".to_string()]));
}
static LOGGER: Logger = Logger;
struct Logger;
impl log::Log for Logger {
fn enabled(&self, metadata: &log::Metadata) -> bool {
metadata.level() <= log::Level::Info
}
fn log(&self, record: &log::Record) {
if self.enabled(record.metadata()) {
println!("{} - {}", record.level(), record.args());
}
}
fn flush(&self) {}
}
fn main() {
log::set_max_level(log::LevelFilter::Debug);
log::set_logger(&LOGGER).unwrap();
log::set_max_level(log::LevelFilter::Info);
unsafe { deno_init() };