logcall
logcall is a Rust procedural macro crate designed to automatically log function calls, their inputs, and their outputs. This macro facilitates debugging and monitoring by providing detailed logs of function executions with minimal boilerplate code.
This is a re-implementation of the log-derive crate with async-trait compatibility.
Installation
Add logcall to your Cargo.toml:
[]
= "0.1"
Usage
Import the logcall crate and use the macro to annotate your functions:
use logcall;
/// Logs the function call at the default `debug` level.
/// Logs the function call at the `info` level.
/// Logs `Ok` results at the `info` level and `Err` results at the `error` level.
/// Logs errors at the `error` level. No log output for `Ok` variant.
/// Logs the function call with custom input logging format.
Log Output
When the main function runs, it initializes the logger and logs each function call as specified:
add => 5
multiply => 6
divide => Err
divide2 => Err
subtract => 1
Customization
- Default Log Level: If no log level is specified,
logcalllogs at thedebuglevel: - Specify Log Level: Use the macro parameters to specify log level:
- Specify Log Levels for
Result: Use theokanderrparameters to specify log levels forOkandErrvariants: - Customize Input Logging: Use the
inputparameter to customize the input log format:
Contributing
Contributions are welcome! Please submit pull requests or open issues to improve the crate.
License
This project is licensed under the MIT License.