#logging #log #slog

slog-extlog

Object-based logging and statistics tracking through logs

13 stable releases (5 major)

8.1.0 Oct 6, 2023
8.0.0 Mar 8, 2022
7.0.0 Mar 4, 2021
6.0.1 Aug 26, 2020
3.2.0 Apr 25, 2018

#389 in Debugging

Download history 259/week @ 2024-08-11 348/week @ 2024-08-18 499/week @ 2024-08-25 474/week @ 2024-09-01 249/week @ 2024-09-08 370/week @ 2024-09-15 453/week @ 2024-09-22 302/week @ 2024-09-29 83/week @ 2024-10-06 225/week @ 2024-10-13 467/week @ 2024-10-20 238/week @ 2024-10-27 359/week @ 2024-11-03 579/week @ 2024-11-10 360/week @ 2024-11-17 364/week @ 2024-11-24

1,663 downloads per month

Apache-2.0

73KB
1K SLoC

This crate adds support for external logs, and for statistics tracking through those logs, to the slog ecosystem.

This crate was written by Metaswitch Networks (@Metaswitch) and made freely available under the Apache License. Contributions are welcome.

Overview

External logs are logs that form an external API that end users can rely on, and that do not change without explicit agreement. Using them allows you to treat logs as objects, rather than strings with metadata, allowing compile-time checking of logs.

This repository provides the following.

  • An API for easily defining external logs.
  • An API for defining statistic values to track, and to modify them based on the external logs
  • A StatisticsLogger type that wraps an slog::Logger, which handles logging and updating tracked stats.
  • An xlog! macro for making the logs through the StatisticsLogger.
  • An API for retrieving the current values of all stats from the StatisticsLogger.

Use of this crate

In theory, an external log can be defined simply by making any type implement ExtLoggable. In practice, external logs will be generated by auto-deriving the ExtLoggable trait using the slog-extlog-derive crate from this repository.

Logs can then be generated by using the xlog! macro to make the logs using a StatisticsLogger - a wrapper around slog::Logger which can also track stats.

For more details, see:

Dependencies

~1.7–8MB
~73K SLoC