#logger #stdweb #log

hobofan_stdweb_logger

Crude logger implementation for use with stdweb

2 releases

Uses old Rust 2015

0.1.1 Jan 24, 2018
0.1.0 Jan 24, 2018

#5 in #stdweb

MIT/Apache

7KB
62 lines

Crude logger implementation for the log crate for use with stdweb - No long-term maintenance intended!

This crate allows you to use the usual log macros from the log crate (info!, debug!, etc.) when working on a project involving stdweb.

The logger will then call the Javascript equivalent in the browser. E.g. info!("Hello World") => console.info("Hello World");.

Caveats

  • Doesn't have module filtering (yet). If you turn the log level to Debug or Trace and your dependencies also log a lot, your console will be very full.

Installation

Add this to your Cargo.toml dependencies:

hobofan_stdweb_logger = "0.1.1"

or run this if you have cargo-edit installed:

cargo add hobofan_stdweb_logger

Usage

#[macro_use]
extern crate stdweb;
#[macro_use]
extern crate log;
extern crate hobofan_stdweb_logger as stdweb_logger;

fn main() {
  stdweb::initialize();
  stdweb_logger::Logger::init_with_level(::log::LevelFilter::Info);

  info!("Hello World!");
}

License

Licensed under either of

Dependencies

~1.3–2MB
~37K SLoC