easy-log 0.1.2

easy to use logger
Documentation
  • Coverage
  • 12.5%
    2 out of 16 items documented0 out of 10 items with examples
  • Size
  • Source code size: 16.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.78 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 18s Average build duration of successful builds.
  • all releases: 18s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tongubin

ezlog - a simple, easy-to-configure, lightweight, action-based logger.

The ezlog crate provides a simple logger. It does not provide any integration with the log API.

The log request consists of an action, input data and output data. Nothing more.

A lot of things are hardcoded, so using this library as-is is not advised. Save it as your own crate.

Install

cargo add easy-log

Usage

The library has a Logger type and a map![] macro.

To build a logger, use the provided methods like this:

use ezlog::{Logger, map, Map};

let default = Logger::new(); // empty
let default2 = Logger::default(); // same as the above

let default = default.ok(); // nothing set => does nothing
let default = default.action("test").ok(); // prints TEST: in green
let default = default.ok();

assert_eq!(
    map![test1: 234],
    Map(&[("test1".to_string(), "234".to_string())]) // auto conversion to String
);

let test2 = "This is a test.";
assert_eq!(
    map![test2],
    Map(&[("test2".to_string(), "This is a test.".to_string())]) // auto expansion
);

// you can chain methods
default
    .action("test2")
    .input(map![test2])
    .output(36) // not only maps
    .warn(); // prints the action in yellow

default2
    .action("test")
    .action("third") // you can override the preferences set before
    .err();

let really = true;
Logger::new()
    .action("final")
    .input(map![what: "test"])
    .output(map![of_what: "of this lib", really])
    .print("purple"); // set a custom color