d4h0 a1335a718c
Support for custom styles and owo_colors (#11)
* init

* Add missing test data

* Implement requested changes

* Rename test/styles.rs and tests/data/style_control.txt

* bump version on owo-colors and run rustfmt

* update control to include source lines

* tweek the documentation a little

* bump version and prep for release

* (cargo-release) start next development iteration 0.1.6-alpha.0

Co-authored-by: d4h0 <d4h0@obyz.de>
Co-authored-by: Jane Lusby <jlusby@yaah.dev>
2020-12-01 17:58:10 -08:00
2020-05-06 13:25:25 -07:00
2020-05-06 13:23:34 -07:00
2020-05-06 13:23:34 -07:00
2020-04-24 16:40:48 -07:00
2020-05-06 15:51:03 -07:00

color-spantrace

Build Status Latest Version Rust Documentation

A rust library for colorizing tracing_error::SpanTrace objects in the style of color-backtrace.

Setup

Add the following to your Cargo.toml:

[dependencies]
color-spantrace = "0.1"
tracing = "0.1.13"
tracing-error = "0.1.2"
tracing-subscriber = "0.2.5"

Setup a tracing subscriber with an ErrorLayer:

use tracing_error::ErrorLayer;
use tracing_subscriber::{prelude::*, registry::Registry};

Registry::default().with(ErrorLayer::default()).init();

Create spans and enter them:

use tracing::instrument;
use tracing_error::SpanTrace;

#[instrument]
fn foo() -> SpanTrace {
    SpanTrace::capture()
}

And finally colorize the SpanTrace:

use tracing_error::SpanTrace;

let span_trace = SpanTrace::capture();
println!("{}", color_spantrace::colorize(&span_trace));

Example

This example is taken from examples/usage.rs:

use tracing::instrument;
use tracing_error::{ErrorLayer, SpanTrace};
use tracing_subscriber::{prelude::*, registry::Registry};

#[instrument]
fn main() {
    Registry::default().with(ErrorLayer::default()).init();

    let span_trace = one(42);
    println!("{}", color_spantrace::colorize(&span_trace));
}

#[instrument]
fn one(i: u32) -> SpanTrace {
    two()
}

#[instrument]
fn two() -> SpanTrace {
    SpanTrace::capture()
}

This creates the following output

Minimal Format

minimal format

Full Format

Full format

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Description
A trait object based error handling type for easy idiomatic error handling and reporting in Rust applications
Readme 3.7 MiB
Languages
Rust 98.6%
Python 1.3%