1 unstable release

new 0.1.1 Feb 12, 2025

#551 in Debugging

Download history 127/week @ 2025-02-11

127 downloads per month

MIT/Apache

63KB
142 lines

Color-Debug

Monkey-patches fmt machinery to colorize debug output.

example

Limitations

This is of course very hacky, so anything may break in the future. Known limitations include:

  • Struct and tuple names can only be colorized on nightly (requires nightly feature flag).
    • Specifically, derived Debug impls use internal shorthand methods which need to be hooked. If they were not, then manual and derived impls would look different.
  • Derived unit structs/variants are not colorized, as they are just a write_str call.
  • Field names are not colored when using nightly-only field_with.
  • References to integer types are only colorized up to a certain depth, due to inlining.

lib.rs:

Monkey-patches fmt machinery to colorize debug output.

Usage

unsafe { color_debug::enable() };

This should only be called once. I make no guarantees about what happens if you call it multiple times.

Dependencies

~1–8.5MB
~76K SLoC