Expand description
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());
}
}
Macros§
- Logs a message at the debug level.
- Logs a message at the error level.
- Logs a message at the info level.
- The standard logging macro.
- Determines if a message logged at the specified level in that module will be logged.
- Logs a message at the trace level.
- Logs a message at the warn level.
Enums§
- An enum representing the available verbosity levels of the logger.
- An enum representing the available verbosity level filters of the logger.