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

Structs

Enums

  • Defines how verbose the backtrace is supposed to be.

Functions

Type Aliases