Crate redis_logger
source ·Expand description
§Redis Logger
This module provides a logger implementation that logs messages to Redis using the log
crate’s Log
trait.
§RedisLogger
RedisLogger
is the main struct in this module. It implements the Log
trait, which allows it to be used as a logger in
applications that use the log
crate. It logs messages to Redis,
either by publishing them to any number of pub/sub channels or by adding them to streams or both.
§RedisLoggerConfig
RedisLoggerConfig
is a struct that holds the configuration for a RedisLogger
.
It includes a Redis connection, a list of pub/sub channels and/or a list of streams to log to,
along with encoders for the messages.
§RedisLoggerConfigBuilder
RedisLoggerConfigBuilder
is a builder for RedisLoggerConfig
. It provides a fluent interface for building a RedisLoggerConfig
.
§PubSubEncoder
and StreamEncoder
PubSubEncoder
and StreamEncoder
are traits for encoding log messages.
They are used by RedisLogger
to encode the messages before sending them to Redis.
The module provides default implementations of these traits when the feature default_encoders
is enabled,
but users can also provide their own implementations.
§Usage
To use this logger, you need to create a RedisLoggerConfig
(using RedisLoggerConfigBuilder
), create a RedisLogger
with the config,
either by calling ::new
or ::init
, the latter of which also sets the logger as the global logger.
§Features
This module has a feature flag default_encoders
that, when enabled, provides default implementations
of PubSubEncoder
and StreamEncoder
that encode the log messages as JSON or as a vector of tuples, respectively.
Structs§
- A logger that logs messages to Redis.
- Configuration for the Redis logger. Pass to
RedisLogger
to configure the logger. RedisLoggerConfigBuilder
is a builder forRedisLoggerConfig
.
Traits§
- Trait for encoding log messages to be published to a pub/sub channel.
- Trait for encoding log messages to be added to a Redis stream.