Crate debug_et_diagnostics

Source
Expand description

set of macros and tools to colorfully debug and diagnose non-trivial code

Modules§

color

Macros§

admonition
colorfully prints an admonition
dbg
colorful alternative to std::dbg
dbg_byte
std::dbg equivalent for u8 which uses format_byte to display the byte
dbg_bytes
std::dbg equivalent for &[u8] which uses [format_bytes] to display the byte slice
dbg_bytes_if_str
[std::dbg_bytes_str] equivalent which only displays debug message if the given bytes are valid UTF-8
dbg_bytes_str
std::dbg equivalent for &[u8] which uses [format_bytes] to display the byte slice in base 16 and string
filename
colofully prints the filename of the macro call
format_byte
colorfully formats a u8 as hex => binary => decimal (=> char (if ascii))
format_bytes
colorfully formats a slice or vector of u8 as hex => binary => decimal (=> char (if ascii))
format_bytes_str
colorfully formats a slice or vector of u8 as hex
format_dbg
format_dbg_location
function_name
returns a String with the name of the function calling the macro
indent
indents an implementor of std::fmt::Display
indent_objdump
indents an implementor of std::fmt::Debug
info
colorfully prints an “INFO” admonition
location
colofully prints the “location” of the macro call (function name, filename and line number) in the code
step
colorfully steps through code
step_dbg
colorfully steps through code debugging given expressions
tag
colorfully wraps the given text in “<”, “>”: “<{text}>”
warn
colorfully prints a “WARN” admonition

Functions§

ansi
colorize the foreground and backrground of the given text and reset the colors afterwards
ansi_clear
clear the screen
auto
auto-colorize the given text with the color determined by from_display
back
colorize the backrground of the given text and reset afterwards
bg
colorize the background of the given text without resetting (ANSI 256 colors)
bgfg
colorize the foreground and backrground of the given text without resetting
bright
naive heuristic to return a brighter color near the given one.
byte
auto-colorize the given byte with the color determined by from_byte
byte_bin
auto-colorize the given byte in bin format with the color determined by from_byte
byte_hex
auto-colorize the given byte in hex format with the color determined by from_byte
couple
returns a tuple of (foreground, backrground) color by taking one unsigned integer, wrapping that around u8::MAX to determine the foreground color then uses invert_bw to determine the background color.
fg
colorize the foreground of the given text without resetting (ANSI 256 colors)
fore
colorize the foreground of the given text and reset afterwards
from_byte
determine an ANSI-256 color determined by [from_bytes(&[byte])]
from_bytes
determine an ANSI-256 color determined by rgb_from_bytes
from_display
auto-colorize the underlying bytes of given text with the color determined by from_bytes
invert_bw
naive heuristic to return the brightest opposite of the given color.
pad
pad text
pad_columns
pad text by the number of columns determined by term_cols
reset
reset the ANSI colors of the given test
rgb_from_bytes
simple and naive algorithm to determine a triple of RGB colors based on XOR’ing the given slice of bytes;
rgb_from_display
determine a triple of RGB colors of a string determined by rgb_from_bytes
term_cols
tries to obtain the number of columns of the terminal via [io_term_cols] and falls back to [DEFAULT_COLUMNS] in case of error.
wrap
wraps the given usize via remainder