Fallback

Trait Fallback 

Source
pub trait Fallback {
    // Provided method
    fn fallback(&self, error: &ServiceError, message: &Message) { ... }
}
Expand description

A strategy for handling log delivery failures.

The Fallback trait defines how the system should react when a log service is unable to process a message after exhausting all retry attempts.

§Use Cases

  • Local Logging: Writing failed logs to stdout, stderr, or a local file.
  • Alerting: Triggering a secondary notification system if critical logs are lost.
  • Buffering: Storing failed messages in a persistent queue for later recovery.

§Thread Safety

Since the worker thread calls this trait’s method, implementations must be thread-safe if they involve shared state.

Provided Methods§

Source

fn fallback(&self, error: &ServiceError, message: &Message)

Handles a message that could not be delivered to the primary service.

This method is invoked by the background worker when a ServiceError occurs that cannot be recovered through retries.

§Default Implementation

The default implementation prints a formatted critical error message to stderr. It includes:

  1. The specific ServiceError description.
  2. An RFC3339-compliant timestamp with nanosecond precision.
  3. The log level and the original message content.

This ensures that even if the remote collector is unreachable, the logs are preserved in the system’s standard error stream.

§Parameters
  • error: The specific error that caused the delivery failure.
  • message: The original log message that failed to be delivered.

Implementors§

Source§

impl Fallback for SimpleCloudWatch

Source§

impl Fallback for StandardLoki

Source§

impl Fallback for Vector

Source§

impl<F> Fallback for BoxedFmt<F>
where F: MessageFormatter + 'static,

Source§

impl<F> Fallback for Cerr<F>
where F: MessageFormatter + 'static,

Source§

impl<F> Fallback for Cout<F>
where F: MessageFormatter + 'static,

Source§

impl<W, F> Fallback for Fmt<W, F>
where W: Write + Send + Sync + 'static, F: MessageFormatter + 'static,

Source§

impl<W, F> Fallback for IoWrite<W, F>
where W: Write + Send + Sync + 'static, F: MessageFormatter + 'static,