Show HN: Rust-loguru – A flexible Rust logging library like Python's Loguru

crates.io

4 points by jraghavan 10 hours ago

I've just released rust-loguru, a logging library for Rust that aims to combine intuitive API design (inspired by Go/Python's Loguru) with Rust's performance characteristics.

Some highlights:

- Consistently outperforms the standard log crate by 50-80% in benchmarks. - Multiple log levels and an extensible handler system -File rotation with better performance than log4rs and other alternatives - Error handling utilities and context helpers

I built this because I wanted a logger that was both ergonomic to use and high-performance. The benchmarks comparing it to slog, log, and tracing are available in the repo.

I'd appreciate any feedback, especially on the API design and performance characteristics. Are there any features you'd like to see added to the roadmap? [GitHub Link: https://github.com/j-raghavan/rust-loguru] [Crates.io: https://crates.io/crates/rust-loguru]

goku12 9 hours ago

Nice project! Python Loguru is a delight to use. Good luck!

So, do you lose any feature, functionality or performance when using loguru as a log crate backend?

  • jraghavan 9 hours ago

    Thanks! Here are the main features

        - Multiple log levels: TRACE, DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL
        - Thread-safe global logger: Safe to use in multi-threaded applications
        - Extensible handler system: Console, file, and custom handlers
        - Configurable log formatting: Customize how log messages are displayed
        - Support for metadata in log records: Add structured data to log messages
        - Convenient logging macros: Easy to use macros for all log levels
        - File rotation: Automatic file rotation based on size with retention policies
        - Colorized output: Colorful console output for better readability
        - Source location capture: Automatically capture file, line, and module information
        - Ergonomic error handling and context helpers: Extension traits, error chain, panic hook, and macros
    
    Have tried to maintain parity with what i loved about loguru. Let me know if you think i missed anything here.