Crate xlog

Source
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§

debug
Logs a message at the debug level.
error
Logs a message at the error level.
info
Logs a message at the info level.
log
The standard logging macro.
log_enabled
Determines if a message logged at the specified level in that module will be logged.
trace
Logs a message at the trace level.
warn
Logs a message at the warn level.

Enums§

Level
An enum representing the available verbosity levels of the logger.
LevelFilter
An enum representing the available verbosity level filters of the logger.