home-prelude

Crates.iohome-prelude
lib.rshome-prelude
version1.0.2
sourcesrc
created_at2024-08-24 21:29:42.716396
updated_at2024-08-24 21:39:00.894814
descriptionPrelude library to support home applications
homepagehttps://github.com/haribo256/home-prelude
repositoryhttps://github.com/haribo256/home-prelude
max_upload_size
id1350566
size6,101
James Harrison (haribo256)

documentation

README

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.
  • 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.

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.

Commit count: 0

cargo fmt