[][src]Crate web_console_logger

A logger for the wasm32-unknown-unknown target that prints all messages to the web console

Usage

#[macro_use]
extern crate log;
extern crate web_console_logger;
extern crate wasm_bindgen;

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn main() {
    web_console_logger::init().unwrap();
    // OR
    // web_console_logger::init_with_level(log::Level::Trace).unwrap();

    trace!("This example message will be logged to the web browser's javascript console.");

    web_console_logger::set_level(log::Level::Warn);

    trace!("This will not be logged, because the log level is now `Warn`.");
    warn!("This will be logged, though.");
}

License

Web Console Logger is licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Functions

init

Initializes logging with a maximum log level of Level::Trace.

init_with_level

Initializes logging with the provided maximum log level.

set_level

Dynamically set the log level.