3 unstable releases

Uses old Rust 2015

0.1.0 Jan 17, 2019
0.0.2 Jun 27, 2018
0.0.1 May 4, 2015

#94 in #log-messages

Download history 104/week @ 2024-06-03 82/week @ 2024-06-10 81/week @ 2024-06-17 67/week @ 2024-06-24 172/week @ 2024-07-01 57/week @ 2024-07-08 132/week @ 2024-07-15 70/week @ 2024-07-22 164/week @ 2024-07-29 194/week @ 2024-08-05 105/week @ 2024-08-12 151/week @ 2024-08-19 41/week @ 2024-08-26 14/week @ 2024-09-02 127/week @ 2024-09-09 69/week @ 2024-09-16

255 downloads per month

MIT/Apache

8KB
96 lines

json_logger

Build Status

Documentation

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

JSON Logger

This logger follows the Bunyan logging format.

Example

#[macro_use] extern crate log;
extern crate json_logger;
extern crate rustc_serialize;

use log::LevelFilter;
use rustc_serialize::json;

#[derive(RustcEncodable)]
struct LogMessage<'a> {
    msg: &'a str,
    event: &'a str
}

fn main() {
    json_logger::init("app_name", LevelFilter::Info).unwrap();

    // This string will show up in the "msg" property
    info!("sample message");

    // This will extend the log message JSON with additional properties
    info!("{}", json::encode(&LogMessage {
        msg: "sample message 2", event: "structured log"
    }).unwrap());
}

Dependencies

~0.9–1.3MB
~21K SLoC