Crate color_backtrace

Source
Expand description

Colorful and clean backtraces on panic.

This library aims to make panics a little less painful by nicely colorizing them, skipping over frames of functions called after the panic was already initiated and printing relevant source snippets. Frames of functions in your application are colored in a different color (red) than those of dependencies (green).

§Screenshot

Screenshot

§Features

  • Colorize backtraces to be easier on the eyes
  • Show source snippets if source files are found on disk
  • Print frames of application code vs dependencies in different color
  • Hide all the frames after the panic was already initiated
  • Hide language runtime initialization frames

§Installing the panic handler

In your main function, just insert the following snippet. That’s it!

color_backtrace::install();

If you want to customize some settings, you can instead do:

use color_backtrace::{default_output_stream, BacktracePrinter};
BacktracePrinter::new().message("Custom message!").install(default_output_stream());

§Controlling verbosity

The default verbosity is configured via the RUST_BACKTRACE environment variable. An unset RUST_BACKTRACE corresponds to minimal, RUST_BACKTRACE=1 to medium and RUST_BACKTRACE=full to full verbosity levels.

Re-exports§

pub use termcolor;

Structs§

BacktracePrinter
Pretty-printer for backtraces and PanicInfo structs.
ColorScheme
Color scheme definition.
Frame

Enums§

Verbosity
Defines how verbose the backtrace is supposed to be.

Traits§

Backtrace
Abstraction over backtrace library implementations.

Functions§

default_frame_filter
The default frame filter. Heuristically determines whether a frame is likely to be an uninteresting frame. This filters out post panic frames and runtime init frames and dependency code.
default_output_stream
Create the default output stream.
install
Install a BacktracePrinter handler with ::default() settings.

Type Aliases§

FilterCallback