Struct RedisLogger

Source
pub struct RedisLogger<CONN, PUBSUB, STREAM>
where CONN: ConnectionLike + Send + Sync, PUBSUB: PubSubEncoder, STREAM: StreamEncoder,
{ /* private fields */ }
Expand description

A logger that logs messages to Redis.

Implementations§

Source§

impl<CONN, PUBSUB, STREAM> RedisLogger<CONN, PUBSUB, STREAM>
where CONN: ConnectionLike + Send + Sync + 'static, PUBSUB: PubSubEncoder + 'static, STREAM: StreamEncoder + 'static,

Source

pub fn new( level: LevelFilter, config: RedisLoggerConfig<CONN, PUBSUB, STREAM>, ) -> Box<Self>

Creates a new instance of RedisLogger with the specified log level and configuration.

§Arguments
  • level - The log level to set for the logger.
  • config - The configuration for the Redis logger.
§Returns

A boxed instance of RedisLogger, not yet initialized as the global logger.

Source

pub fn init( level: LevelFilter, config: RedisLoggerConfig<CONN, PUBSUB, STREAM>, ) -> Result<(), SetLoggerError>

Initializes the Redis logger with the specified log level and configuration.

§Arguments
  • level - The log level to set for the logger.
  • config - The configuration for the Redis logger.
§Returns

Result indicating success or an error of type RedisLoggerConfigError. If successful, the logger is set as the global logger.

§Errors

see above

Trait Implementations§

Source§

impl<CONN, PUBSUB, STREAM> Debug for RedisLogger<CONN, PUBSUB, STREAM>
where CONN: ConnectionLike + Send + Sync + Debug, PUBSUB: PubSubEncoder + Debug, STREAM: StreamEncoder + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<CONN, PUBSUB, STREAM> Log for RedisLogger<CONN, PUBSUB, STREAM>
where CONN: ConnectionLike + Send + Sync, PUBSUB: PubSubEncoder, STREAM: StreamEncoder,

Implements the Log trait for the RedisLogger struct.

This implementation provides the necessary methods to enable logging to Redis. The enabled method checks if the log level of the provided Metadata is less than or equal to the configured log level. The log method publishes log messages to Redis channels and streams based on the configuration in one atomic operation using a pipeline. The flush method is a no-op in this implementation.

Source§

fn enabled(&self, metadata: &Metadata<'_>) -> bool

Determines if a log message with the specified metadata would be logged. Read more
Source§

fn log(&self, record: &Record<'_>)

Logs the Record. Read more
Source§

fn flush(&self)

Flushes any buffered records. Read more
Source§

impl<CONN, PUBSUB, STREAM> SharedLogger for RedisLogger<CONN, PUBSUB, STREAM>
where CONN: ConnectionLike + Send + Sync + 'static, PUBSUB: PubSubEncoder + 'static, STREAM: StreamEncoder + 'static,

Available on crate feature shared_logger only.
Source§

fn level(&self) -> LevelFilter

Returns the set Level for this Logger Read more
Source§

fn config(&self) -> Option<&Config>

Inspect the config of a running Logger Read more
Source§

fn as_log(self: Box<Self>) -> Box<dyn Log>

Returns the logger as a Log trait object

Auto Trait Implementations§

§

impl<CONN, PUBSUB, STREAM> !Freeze for RedisLogger<CONN, PUBSUB, STREAM>

§

impl<CONN, PUBSUB, STREAM> RefUnwindSafe for RedisLogger<CONN, PUBSUB, STREAM>
where PUBSUB: RefUnwindSafe, STREAM: RefUnwindSafe,

§

impl<CONN, PUBSUB, STREAM> Send for RedisLogger<CONN, PUBSUB, STREAM>

§

impl<CONN, PUBSUB, STREAM> Sync for RedisLogger<CONN, PUBSUB, STREAM>

§

impl<CONN, PUBSUB, STREAM> Unpin for RedisLogger<CONN, PUBSUB, STREAM>
where CONN: Unpin, PUBSUB: Unpin, STREAM: Unpin,

§

impl<CONN, PUBSUB, STREAM> UnwindSafe for RedisLogger<CONN, PUBSUB, STREAM>
where PUBSUB: UnwindSafe, STREAM: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T