Skip to content

Commit

Permalink
Implement a logger so we can get logging output.
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 29, 2018
1 parent 57c52a8 commit e744550
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
21 changes: 20 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() };

Expand Down

0 comments on commit e744550

Please sign in to comment.