Crates.io | easy-log |
lib.rs | easy-log |
version | 0.1.2 |
source | src |
created_at | 2024-02-03 01:16:41.272253 |
updated_at | 2024-02-04 12:47:07.406088 |
description | easy to use logger |
homepage | |
repository | https://github.com/jilotta/ezlog |
max_upload_size | |
id | 1124963 |
size | 6,868 |
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.
cargo add easy-log
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