Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color-spantrace to monorepo #105

Merged
merged 47 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c2ac450
Initial commit of color-spantrace
yaahc Apr 24, 2020
20b490c
update to match color-backtrace
yaahc May 1, 2020
efd4061
get that bat outtahere
yaahc May 2, 2020
b7274c9
switch to ansi_term
yaahc May 6, 2020
b0c867c
Prep for release
yaahc May 6, 2020
0c43f82
Add ci
yaahc May 6, 2020
b867bf4
Fix links in readme
yaahc May 6, 2020
6b58982
Fix link in readme
yaahc May 6, 2020
2e78274
clippy
yaahc May 6, 2020
208cb84
final prep before release
yaahc May 6, 2020
fb630e1
match color-backtrace behavior
yaahc May 7, 2020
3855477
fix intensity of colors (#2)
yaahc Jun 3, 2020
8461547
Dedupdep (#3)
yaahc Jun 3, 2020
1f1aeb7
colorize line numbers and fix indentation issue (#7)
yaahc Jun 25, 2020
0769344
bump version for new release (#8)
yaahc Jul 6, 2020
a1335a7
Support for custom styles and owo_colors (#11)
d4h0 Dec 2, 2020
edfcda0
ignore all io errors while resolving source files
yaahc Dec 2, 2020
8049927
prep for release
yaahc Dec 2, 2020
2eebd84
(cargo-release) version 0.1.6
yaahc Dec 2, 2020
f7e61e6
ignore all io errors while resolving source files (#12)
yaahc Dec 2, 2020
1d40228
Fix lint warnings
asonix Dec 26, 2021
99371c3
Update tracing-error (and tracing-subscriber)
asonix Dec 26, 2021
3080506
Update ansi-parser
asonix Dec 26, 2021
37d4dce
Update owo-colors
asonix Dec 26, 2021
444e672
Merge pull request #14 from asonix/asonix/update-tracing-error
yaahc Jan 12, 2022
52c6cc1
Merge branch 'master' into asonix/update-ansi-parser
yaahc Jan 12, 2022
3de5d08
Merge branch 'master' into asonix/fix-warnings
yaahc Jan 12, 2022
1b9c9bd
Merge branch 'master' into asonix/update-owo-colors
yaahc Jan 12, 2022
9350c4f
Update Cargo.toml
yaahc Jan 12, 2022
43ed8a5
Merge pull request #15 from asonix/asonix/fix-warnings
yaahc Jan 12, 2022
77da3e7
Merge branch 'master' into asonix/update-owo-colors
yaahc Jan 12, 2022
d5e3aa4
Merge branch 'master' into asonix/update-ansi-parser
yaahc Jan 12, 2022
e5c13ca
Merge pull request #17 from asonix/asonix/update-owo-colors
yaahc Jan 12, 2022
a61d863
Merge branch 'master' into asonix/update-ansi-parser
yaahc Jan 12, 2022
58b8be7
Merge pull request #16 from asonix/asonix/update-ansi-parser
yaahc Jan 12, 2022
c0ec5ff
Prepare for 0.2 release
yaahc Jan 12, 2022
1553836
(cargo-release) version 0.2.0
yaahc Jan 13, 2022
ac0cbcc
Merge pull request #18 from yaahc/release
yaahc Jan 13, 2022
35031dc
Add license files
erickt May 5, 2022
1a52aac
Merge pull request #19 from erickt/master
yaahc May 5, 2022
b40a66d
Add 'color-spantrace/' from commit '1a52aac2b55a05efc64807f06b9141455…
pksunkara Oct 3, 2023
e42d667
Add color-spantrace to workspace
pksunkara Oct 3, 2023
22b871b
fix: color-spantrace test due to misinterpreted relative paths
ten3roberts Oct 10, 2023
e54e98f
fix: color-spantrace does not work in miri sandbox
ten3roberts Oct 10, 2023
0ad6355
chore: clarify file! behavior
ten3roberts Oct 10, 2023
0d7f941
fix: unused imports under miri
ten3roberts Oct 10, 2023
e610c81
Merge pull request #109 from eyre-rs/fix-color-spantrace-test
ten3roberts Oct 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = [
"color-spantrace",
"eyre"
]

Expand Down
2 changes: 2 additions & 0 deletions color-spantrace/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
28 changes: 28 additions & 0 deletions color-spantrace/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- next-header -->

## [Unreleased] - ReleaseDate

## [0.2.0] - 2022-01-12
### Changed
- Updated dependency versions to match latest tracing versions

## [0.1.6] - 2020-12-02
### Fixed
- Ignore all io errors when resolving source files instead of only file not
found errors

## [v0.1.5] - 2020-12-01
### Added
- Support custom color themes for spantrace format

<!-- next-url -->
[Unreleased]: https://github.com/eyre-rs/color-spantrace/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/eyre-rs/color-spantrace/compare/v0.1.6...v0.2.0
[0.1.6]: https://github.com/eyre-rs/color-spantrace/compare/v0.1.5...v0.1.6
[v0.1.5]: https://github.com/eyre-rs/color-spantrace/releases/tag/v0.1.5
64 changes: 64 additions & 0 deletions color-spantrace/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[package]
name = "color-spantrace"
version = "0.2.0"
description = "A pretty printer for tracing_error::SpanTrace based on color-backtrace"
documentation = "https://docs.rs/color-spantrace"

authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
readme = { workspace = true }
rust-version = { workspace = true }

[dependencies]
tracing-error = "0.2.0"
tracing-core = "0.1.21"
owo-colors = "3.2.0"
once_cell = { workspace = true }

[dev-dependencies]
tracing-subscriber = "0.3.4"
tracing = "0.1.29"
ansi-parser = "0.8" # used for testing color schemes

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.release]
dev-version = false

[[package.metadata.release.pre-release-replacements]]
file = "CHANGELOG.md"
search = "Unreleased"
replace="{{version}}"

[[package.metadata.release.pre-release-replacements]]
file = "src/lib.rs"
search = "#!\\[doc\\(html_root_url.*"
replace = "#![doc(html_root_url = \"https://docs.rs/{{crate_name}}/{{version}}\")]"
exactly = 1

[[package.metadata.release.pre-release-replacements]]
file = "CHANGELOG.md"
search = "\\.\\.\\.HEAD"
replace="...{{tag_name}}"
exactly = 1

[[package.metadata.release.pre-release-replacements]]
file = "CHANGELOG.md"
search = "ReleaseDate"
replace="{{date}}"

[[package.metadata.release.pre-release-replacements]]
file="CHANGELOG.md"
search="<!-- next-header -->"
replace="<!-- next-header -->\n\n## [Unreleased] - ReleaseDate"
exactly=1

[[package.metadata.release.pre-release-replacements]]
file="CHANGELOG.md"
search="<!-- next-url -->"
replace="<!-- next-url -->\n[Unreleased]: https://github.com/eyre-rs/{{crate_name}}/compare/{{tag_name}}...HEAD"
exactly=1
1 change: 1 addition & 0 deletions color-spantrace/LICENSE-APACHE
1 change: 1 addition & 0 deletions color-spantrace/LICENSE-MIT
110 changes: 110 additions & 0 deletions color-spantrace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
color-spantrace
===============

[![Build Status][actions-badge]][actions-url]
[![Latest Version](https://img.shields.io/crates/v/color-spantrace.svg)](https://crates.io/crates/color-spantrace)
[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/color-spantrace)

[actions-badge]: https://github.com/eyre-rs/color-spantrace/workflows/Continuous%20integration/badge.svg
[actions-url]: https://github.com/eyre-rs/color-spantrace/actions?query=workflow%3A%22Continuous+integration%22

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

## Setup

Add the following to your `Cargo.toml`:

```toml
[dependencies]
color-spantrace = "0.2"
tracing = "0.1"
tracing-error = "0.2"
tracing-subscriber = "0.3"
```

Setup a tracing subscriber with an `ErrorLayer`:

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

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

Create spans and enter them:

```rust
use tracing::instrument;
use tracing_error::SpanTrace;

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

And finally colorize the `SpanTrace`:

```rust
use tracing_error::SpanTrace;

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

## Example

This example is taken from `examples/usage.rs`:

```rust
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](./pictures/minimal.png)

### Full Format

![Full format](./pictures/full.png)

#### License

<sup>
Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
</sup>

<br>

<sub>
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.
</sub>

[`tracing_error::SpanTrace`]: https://docs.rs/tracing-error/*/tracing_error/struct.SpanTrace.html
[`color-backtrace`]: https://github.com/athre0z/color-backtrace
21 changes: 21 additions & 0 deletions color-spantrace/examples/usage.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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()
}
Binary file added color-spantrace/pictures/full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added color-spantrace/pictures/minimal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading