tincre-logger: A logging wrapper for Rust projects
tincre-logger is a simple, "zero-setup" logging library for Rust that works out-of-the-box with a familiar API.
It's designed to be efficient and easy to use, providing automatic initialization on the first log call.
Here are the logging functions included in this library:
log()/info()for informational messages.warn()for warnings.error()for errors.debug()for verbose debugging messages.info_with(),warn_with(),error_with(), anddebug_with()for structured logs with JSON metadata.
This library leverages tracing to provide structured, high-performance logging with minimal boilerplate.
Features
- Zero-Setup Logging: Automatically initializes on the first log call. No manual
init()function is required in your application'smain. - Simple, Familiar API: Provides
log(),info(),warn(),error(), anddebug()functions in a flatloggermodule. - Structured Logging Support: Use the
_with()variants to attach JSON-serializable metadata to any log message. - Environment Configuration: Respects the standard
RUST_LOGenvironment variable to control log levels (e.g.,RUST_LOG=debug). - Colored Console Output: Prints colorful, easy-to-read logs to the console by default.
- Fully Tested: Includes a full suite of unit and integration tests to ensure reliability and correctness.
Installation
Add tincre-logger to your Cargo.toml:
cargo add tincre-logger
Usage
use logger;
use json;
To see the debug-level logs, run your application with the RUST_LOG environment variable:
RUST_LOG=debug cargo run
License
This project is licensed under the MIT License.