10 releases
0.2.2 | Nov 20, 2020 |
---|---|
0.2.1 | Aug 12, 2020 |
0.1.8 | Jul 25, 2020 |
#18 in #log-line
9KB
128 lines
Xlog can add key/value pairs to your log lines.
Documentation
lib.rs
:
Xlog can add key/value pairs to your log lines.
It's fully compatible with log
crate, only extended support for key/value pairs, and is rustfmt friendly.
Target syntax
There is no difference between the following two lines of code, the first is for compatibility with log crates, and the second is friendly to rustfmt.
use xlog::info;
info!(target: "a", "hello");
info!(target = "a", "hello");
Error Key
use xlog::error;
use std::io::{Error, ErrorKind};
error!("Failed to open database", error = Error::from(ErrorKind::InvalidData).to_string())
Examples
use xlog::{info, error};
pub fn serve(bind_addr: &str) {
info!(target: "http", "Start server", bind_addr = bind_addr);
if let Some(err) = start_http_server(bind_addr) {
error!(target: "http", "Failed to start server", error = err.to_string());
}
}
Dependencies
~320KB