10 releases

0.2.2 Nov 20, 2020
0.2.1 Aug 12, 2020
0.1.8 Jul 25, 2020

#693 in HTTP server

Download history 71/week @ 2023-10-29 70/week @ 2023-11-05 77/week @ 2023-11-12 89/week @ 2023-11-19 89/week @ 2023-11-26 95/week @ 2023-12-03 67/week @ 2023-12-10 79/week @ 2023-12-17 96/week @ 2023-12-24 84/week @ 2023-12-31 78/week @ 2024-01-07 68/week @ 2024-01-14 86/week @ 2024-01-21 94/week @ 2024-01-28 65/week @ 2024-02-04 115/week @ 2024-02-11

372 downloads per month

MIT/Apache

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

~260KB