9 stable releases (3 major)
4.0.1 | May 4, 2023 |
---|---|
4.0.0 | Sep 26, 2022 |
3.0.0 | Jan 21, 2022 |
2.0.1 | Oct 19, 2021 |
1.1.0 |
|
#372 in Command-line interface
20KB
507 lines
tinylog
A logger for my personal projects. Major version increases may occur at any time.
Goals
- Fast
- Write to a thread-local string before writing it to output. This way, all logic can occur before the lock, saving time in multi-threaded scenarios.
- Avoid
dyn
when possible. - Avoid
std::fmt::Formatter
. It usesdyn
and every write produces aResult
.
- Minimal
- Only provide configuration when it would be difficult to produce the same behavior without it.
- The default configuration should work for most scenarios.
- Avoid dependency bloat. Make them optional if possible, and disable their default features.
- Pretty
- Use colors.
- Print things in a human-friendly format.
lib.rs
:
Configuration
Output, color, and timezone can be configured on the Logger
.
Features
detect-color
- Automatically detect terminal color support.detect-timezone
- Iftimestamps
are enabled, the local timezone will automatically be detected and used.log
- Enable [log
] support.parking_lot
- Useparking_lot
internally.timestamps
- Enable timestamps.tracing
- Enabletracing
support.
Log level
Set the level using log
or tracing
directly.
Filtering
To add filtering with [log
], create a new struct that implements Log::enabled
, and forward
the other methods to tinylog::Logger
.
For tracing
, tracing_subscriber
already lets you add filters to existing layers.
Dependencies
~0–7.5MB
~46K SLoC