iprint-rs
iprint-rs is a Rust utility library for indented printing and logging, designed to help you easily trace the execution of your code. The library provides a suite of macros for indented formatting (iformat), simplified indented printing (iprintln), and logging with varying levels (itrace, idebug, iinfo, iwarn, ierror). All features are geared to improve debugging and code tracing by automatically adjusting indentation based on the function call depth.
⚠️ Warning
This library may not function correctly when compiled in release mode due to function inlining. It is recommended to use it in debug mode for accurate results.
Features
- iprintln! macro: This is an enhanced version of
println!, adding automatic indentation. - iformat! macro: The
iformatmacro allows for custom indented formatting. - call_depth! macro: The
call_depthmacro provides the current depth of the function call stack, useful for custom logging or tracing solutions. - indented logging: Provides five levels of logging (
itrace,idebug,iinfo,iwarn,ierror) that are feature-gated by thelogfeature.
Installation
To include iprint-rs in your project, add the following to your Cargo.toml:
[]
= "0.1.4" # Use the latest version
To enable logging functionalities, update your Cargo.toml like so:
[]
= { = "0.1.4", = ["log"] }
Usage
iprintln! macro
use iprintln;
iformat! macro
use iformat;
call_depth! macro
use call_depth;
logging functions (feature-gated)
To use logging functions, make sure you have the log feature enabled.
use iinfo;
License
This project is licensed under the MIT License. See the LICENSE.md file for details.