emit 0.3.0

An experimental structured event emitter, currently work-in-progress.
docs.rs failed to build emit-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: emit-0.10.0

I'm learning Rust by implementing a structured logging API similar to the one found in Serilog.

Log events consist of a format and list of named arguments:

#[macro_use]
extern crate emit;

use std::env;

fn main() {
    let _flush = emit::pipeline::init("http://localhost:5341/", None);
            
    emit!("Hello, {}!", name: env::var("USERNAME").unwrap());
}

These end up in JSON payloads like:

{
  "Timestamp": "2016-03-17T00:17:01Z",
  "MessageTemplate": "Hello, {name}!",
  "Properties": {
    "name": "nblumhardt"
  }
}

Which can be rendered out to text or searched/sorted/filtered based on the event properties:

Event in Seq

I'm using Seq and its JSON format while I design the crate, but like Serilog this should eventually be pluggable to other log collectors and formats.

What about the log crate?

The log!() macros are obviously the best way to capture diagnostic events in Rust as it stands. However, log destructively renders events into text:

info!("Hello, {}!", env::var("USERNAME").unwrap());

There's no way for a log processing system to later pull the username value from this message, except through handwritten parsers/regular expressions.

The idea of emit is that rendering can happen at any point - but the original values are preserved for easy machine processing as well.