1 unstable release
Uses old Rust 2015
0.1.0 | Jul 24, 2019 |
---|
#75 in #structured
11KB
178 lines
A Tiny Structured Logging Utility
This is a lightweight logging utility that does little more than structure messages consistently and print them to standard out.
This logging facility is a simple object that should be passed around to anything that needs to do logging. I recommend making it a part of your application context so that it is simply passed along with the rest of your application information. Begin by instantiating the object:
let logger = micrologger::Logger::new(micrologger::json_stdout, "a-host", "an-app")
This API is fairly low-level and works best if clients wrap helper functions to build the log entries around the basic logging function.
fn log_app_start(logger: micrologger::Logger) {
logger.log("app-start", HashMap::new());
}
fn log_method_start(logger: micrologger::Logger, method_name: str) {
let mut msg = Hashmap::new();
msg.insert("method-name", method_name);
logger.log("method-start", msg);
}
Dependencies
~1.6–2.7MB
~52K SLoC