#http-request #http-response #request-response #tcp #redirect #http #request

hyperlane-log

A Rust logging library that supports both asynchronous and synchronous logging. It provides multiple log levels, such as error, info, and debug. Users can define custom log handling methods and configure log file paths. The library supports log rotation, automatically creating a new log file when the current file reaches the specified size limit. It allows flexible logging configurations, making it suitable for both high-performance asynchronous applications and traditional synchronous logging scenarios. The asynchronous mode utilizes Tokio's async channels for efficient log buffering, while the synchronous mode writes logs directly to the file system.

96 releases (53 stable)

Uses new Rust 2024

new 1.10.8 Mar 30, 2025
1.1.30 Feb 26, 2025
0.29.5 Jan 13, 2025
0.5.0 Dec 31, 2024

#1718 in Network programming

Download history 176/week @ 2024-12-22 1594/week @ 2024-12-29 2718/week @ 2025-01-05 827/week @ 2025-01-12 1811/week @ 2025-01-19 28/week @ 2025-01-26 754/week @ 2025-02-02 674/week @ 2025-02-09 817/week @ 2025-02-16 421/week @ 2025-02-23 789/week @ 2025-03-02 415/week @ 2025-03-09 561/week @ 2025-03-16 1672/week @ 2025-03-23

3,456 downloads per month
Used in 5 crates (3 directly)

MIT license

17KB
301 lines

hyperlane-log

Official Documentation

Api Docs

A Rust logging library that supports both asynchronous and synchronous logging. It provides multiple log levels, such as error, info, and debug. Users can define custom log handling methods and configure log file paths. The library supports log rotation, automatically creating a new log file when the current file reaches the specified size limit. It allows flexible logging configurations, making it suitable for both high-performance asynchronous applications and traditional synchronous logging scenarios. The asynchronous mode utilizes Tokio's async channels for efficient log buffering, while the synchronous mode writes logs directly to the file system.

Installation

To use this crate, you can run cmd:

cargo add hyperlane-log

Log Storage Location Description

Three directories will be created under the user-specified directory: one for error logs, one for info logs, and one for debug logs. Each of these directories will contain a subdirectory named by the date, and the log files within these subdirectories will be named in the format timestamp.index.log.

Use sync

use hyperlane_log::*;
let log: Log = Log::new("./logs", 1_024_000);
log.error("error data!", |error| {
    let write_data: String = format!("User error func =>  {:?}\n", error);
    write_data
});
log.info("info data!", |info| {
    let write_data: String = format!("User info func =>  {:?}\n", info);
    write_data
});
log.debug("debug data!", |debug| {
    let write_data: String = format!("User debug func =>  {:#?}\n", debug);
    write_data
});

Use async

use hyperlane_log::*;
let log: Log = Log::new("./logs", 1_024_000);
log.async_error("async error data!", |error| {
    let write_data: String = format!("User error func =>  {:?}\n", error);
    write_data
});
log.async_info("async info data!", |info| {
    let write_data: String = format!("User info func =>  {:?}\n", info);
    write_data
});
log.async_debug("async debug data!", |debug| {
    let write_data: String = format!("User debug func =>  {:#?}\n", debug);
    write_data
});

Disable log

let log: Log = Log::new("./logs", DISABLE_LOG_FILE_SIZE);

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Contact

For any inquiries, please reach out to the author at ltpp-universe root@ltpp.vip.

Dependencies

~2.6–8.5MB
~74K SLoC