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 Aug 31, 2021

#240 in Debugging

39 downloads per month

MIT license

20KB
507 lines

tinylog

A logger for my personal projects. Major version increases may occur at any time.

Documentation

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 uses dyn and every write produces a Result.
  • 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 - If timestamps are enabled, the local timezone will automatically be detected and used.
  • log - Enable [log] support.
  • parking_lot - Use parking_lot internally.
  • timestamps - Enable timestamps.
  • tracing - Enable tracing 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–9.5MB
~57K SLoC