#log #go #package #standard #modeled

logosaurus

Logging implementation modeled after the Go standard library's log package

10 releases (4 breaking)

0.5.0 Oct 6, 2020
0.4.1 Oct 6, 2020
0.3.4 Oct 3, 2020
0.2.0 Oct 2, 2020
0.1.1 Oct 2, 2020

#499 in Debugging

MIT license

17KB
275 lines

logosaurus

crates.io docs.rs

Rust logging implementation modeled after the Go standard library log package. It works with the log crate.

Documentation

See docs.rs.

Examples

Using the default logger

use log::{debug};
use logosaurus::{Logger};

fn main() {
  logosaurus::init(Logger::default()).unwrap();
  debug!("hello, world"); // DEBUG 2020/10/02 21:27:03 hello, world
}

Using a custom logger

use log::{self, debug};
use logosaurus::{Logger, L_STD, L_SHORT_FILE, L_MICROSECONDS};
use std::io;

fn main() {
  let logger = Logger::builder(io::stdout())
                  .set_level(log::LevelFilter::Debug)
                  .set_flags(L_STD | L_SHORT_FILE | L_MICROSECONDS)
                  .set_prefix("myprogram: ")
                  .build();

  logosaurus::init(logger).unwrap();
  debug!("hello, world"); // myprogram: DEBUG 2020/10/02 21:27:03.123123 main.rs:12: hello, world
}

Dependencies

~1.5MB
~20K SLoC