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

Constants§

STD_COLORS

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
auto_bright
brighter version of auto
auto_dark
darker version of auto
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
return a brighter color near the given one via bright_rgb_band.
bright_rgb_band
return a brighter color from the given rgb band
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.
cube_ansi_256
dark
return a darker color near the given one via dark_rgb_band.
dark_rgb_band
return a darker color from the given rgb band
fg
colorize the foreground of the given text without resetting (ANSI 256 colors)
fore
colorize the foreground of the given text and reset afterwards
format_slice_debug
format_slice_display
format_slice_hex
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_debug
auto-colorize the underlying bytes of given text with the color determined by from_bytes
from_display
auto-colorize the underlying bytes of given text with the color determined by from_bytes
get_ansi_rgb
invert_ansi
converts the given color to rgb triple then inverts the rgb and converts back to ansi256
invert_bw
brings the color to grayscale then inverts it
invert_rgb
converts the given color to rgb triple then inverts the rgb and converts back to ansi256
is_bright_rgb_band
return true if the given rgb band is bright
is_dark_rgb_band
return true if the given rgb band is dark
merge_rgb
merges a sequence of slice [u8; 3] into a single slice [u8; 3]
non_zero_be_bytes
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_byte
returns a [red, green, blue] slice [u8; 3] from a single byte
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
rgb_to_byte
returns a [red, green, blue] slice [u8; 3] from a single byte
term_cols
tries to obtain the number of columns of the [DEFAULT_COLUMNS] in case of error.
wrap
wraps the given usize via remainder