3 stable releases
1.0.2 | Aug 24, 2024 |
---|
#652 in Rust patterns
58 downloads per month
7KB
home-prelude
is a Rust library designed to simplify the setup of tracing and error handling for Rust applications.
It provides pre-configured tracing and error output configurations that can be quickly integrated into binary projects, especially those intended to run in a home or personal environment.
Features
- Pre-configured Tracing: Set up tracing with sensible defaults, including custom time formatting, ANSI color support, and panic hooks.
- Enhanced Error Reporting: Leverage
color-eyre
for better error reporting. - Unified Error Type: Use the
StdResult
type alias for consistent error handling across your application.
Getting Started
Installation
Add home-prelude
to your Cargo.toml
:
[dependencies]
home-prelude = "1"
Usage
To use home-prelude
in your Rust project, you need to set up tracing and error handling at the start of your application:
use home_prelude::{configure_tracing, configure_color_eyre, StdResult};
fn main() -> StdResult {
// Configure tracing and error handling
configure_tracing();
configure_error_output();
// Your application logic goes here
Ok(())
}
Configuration Details
-
Tracing Configuration:
- Tracing output is sent to
stderr
. - Custom time format (
%Y-%m-%d %H:%M:%S
) for log timestamps. - Optionally disables ANSI colors based on the
NO_COLOR
environment variable. - Disables the inclusion of thread names, thread IDs, target, file, and line numbers in logs for cleaner output.
- Tracing output is sent to
-
Error Handling Configuration:
- Integrates
color-eyre
for enhanced error reporting. - Automatically switches between color themes based on the presence of the
NO_COLOR
environment variable.
- Integrates
Contributing
Contributions are welcome! Please check out the issues for tasks to work on. If you find a bug or have a feature request, feel free to open an issue.
Acknowledgments
- This library is built on top of the great work from the Rust community, especially the creators and maintainers of
tracing
,color-eyre
, and other dependencies.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contact
For any questions or support, please open an issue or contact the maintainer via the repository's homepage.
Dependencies
~6–12MB
~129K SLoC