emit 0.9.1

A structured logger in the style of Serilog.
docs.rs failed to build emit-0.9.1
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

emit Join the chat at https://gitter.im/serilog/serilog Crates.io

This crate implements a structured logging API similar to the one in Serilog. In systems programming, this style of logging is most often found in Windows' ETW. Web and distributed applications use similar techniques to improve machine-readabililty when dealing with large event volumes.

"Emitted" log events consist of a format and list of named properties, as in the eminfo!() call below.

#[macro_use]
extern crate emit;

use std::env;
use emit::PipelineBuilder;
use emit::collectors::seq;

fn main() {
    let _flush = PipelineBuilder::new()
        .at_level(emit::LogLevel::Info)
        .send_to(seq::SeqCollector::new_local())
        .init();
            
    eminfo!("Hello, {}!", name: env::var("USERNAME").unwrap());
}

The named arguments are captured as key/value properties that can be rendered in a structured format such as JSON:

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

This makes log searches in an appropriate back-end collector much simpler:

Event in Seq

Seq and its JSON format are implemented for the work-in-progress here, but support for other log collectors and formats is on its way.

If you don't have Seq running, events can be written to io::stdout instead:

use emit::collectors::stdio::StdioCollector;
let _flush = PipelineBuilder::new()
    .write_to(StdioCollector::new())
    .init();

Produces:

emit 2016-03-24T05:03:36Z INFO  Hello, {name}!
  name: "nblumhardt"
  target: "web_we_are"

What about the log crate?

The log!() macros are the established way to capture diagnostic events in Rust today. 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.

To keep these two worlds in harmony, emit will be able to mirror events to log (#7).