Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ categories = []
keywords = []

[features]
default = ["track-caller", "capture-spantrace"]
default = ["track-caller", "capture-spantrace", "show-backtrace"]
capture-spantrace = ["tracing-error", "color-spantrace"]
issue-url = ["url"]
track-caller = []
show-backtrace = []

[dependencies]
eyre = "0.6.1"
Expand Down
6 changes: 6 additions & 0 deletions src/writers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,15 @@ impl fmt::Display for EnvSection<'_> {
} else {
lib_verbosity()
};
#[cfg(feature = "show-backtrace")]
write!(f, "{}", BacktraceOmited(!self.bt_captured))?;

let mut separated = HeaderWriter {
inner: &mut *f,
header: &"\n",
started: false,
};
#[cfg(feature = "show-backtrace")]
write!(&mut separated.ready(), "{}", SourceSnippets(v))?;
#[cfg(feature = "capture-spantrace")]
write!(
Expand Down Expand Up @@ -223,8 +225,10 @@ impl fmt::Display for SpanTraceOmited<'_> {
}
}

#[cfg(feature = "show-backtrace")]
struct BacktraceOmited(bool);

#[cfg(feature = "show-backtrace")]
impl fmt::Display for BacktraceOmited {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Print some info on how to increase verbosity.
Expand All @@ -245,8 +249,10 @@ impl fmt::Display for BacktraceOmited {
}
}

#[cfg(feature = "show-backtrace")]
struct SourceSnippets(Verbosity);

#[cfg(feature = "show-backtrace")]
impl fmt::Display for SourceSnippets {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.0 <= Verbosity::Medium {
Expand Down