21 releases

0.11.0-alpha.21 Oct 21, 2024
0.11.0-alpha.20 Oct 20, 2024
0.11.0-alpha.17 Sep 20, 2024
0.11.0-alpha.13 Aug 29, 2024
0.11.0-alpha.6 Jun 28, 2024

#831 in Debugging

Download history 131/week @ 2024-07-29 1/week @ 2024-08-05 118/week @ 2024-08-12 156/week @ 2024-08-19 552/week @ 2024-08-26 438/week @ 2024-09-09 347/week @ 2024-09-16 56/week @ 2024-09-23 146/week @ 2024-09-30 28/week @ 2024-10-07 409/week @ 2024-10-14 230/week @ 2024-10-21 22/week @ 2024-10-28 31/week @ 2024-11-04

694 downloads per month
Used in emit_traceparent

MIT/Apache

2.5MB
6.5K SLoC

Rust 4.5K SLoC // 0.2% comments JavaScript 2K SLoC // 0.0% comments

emit_term

term

Current docs

Emit diagnostic events to the console.

This library implements a text-based format that's intended for direct end-user consumption, such as in interactive applications.


lib.rs:

Emit diagnostic events to the console.

This library implements a text-based format that's intended for direct end-user consumption, such as in interactive applications.

Getting started

Add emit and emit_term to your Cargo.toml:

[dependencies.emit]
version = "0.11.0-alpha.21"

[dependencies.emit_term]
version = "0.11.0-alpha.21"

Initialize emit using emit_term:

fn main() {
let rt = emit::setup()
.emit_to(emit_term::stdout())
.init();

// Your app code goes here

rt.blocking_flush(std::time::Duration::from_secs(30));
}

emit_term uses a format optimized for human legibility, not for machine processing. You may also want to emit diagnostics to another location, such as OTLP through emit_otlp or a rolling file through emit_file for processing. You can use emit::Setup::and_emit_to to combine multiple emitters:

fn main() {
let rt = emit::setup()
.emit_to(emit_term::stdout())
.and_emit_to(some_other_emitter())
.init();

// Your app code goes here

rt.blocking_flush(std::time::Duration::from_secs(30));
}

Configuration

emit_term has a fixed format, but can be configured to force or disable color output instead of detect it.

To disable colors, call Stdout::colored with the value false:

fn main() {
let rt = emit::setup()
// Disable colors
.emit_to(emit_term::stdout().colored(false))
.init();

// Your app code goes here

rt.blocking_flush(std::time::Duration::from_secs(5));
}

To force colors, call Stdout::colored with the value true:

fn main() {
let rt = emit::setup()
// Force colors
.emit_to(emit_term::stdout().colored(true))
.init();

// Your app code goes here

rt.blocking_flush(std::time::Duration::from_secs(5));
}

Dependencies

~2.2–9.5MB
~99K SLoC