Entry

Enum Entry 

Source
pub enum Entry {
    Silent {},
    StdOut {
        concurrency: Concurrency,
        max_retries: Option<usize>,
        worker_count: Option<usize>,
    },
    StdErr {
        concurrency: Concurrency,
        max_retries: Option<usize>,
        worker_count: Option<usize>,
    },
    File {
        path: String,
        concurrency: Concurrency,
        max_retries: Option<usize>,
        worker_count: Option<usize>,
    },
    BufferedFile {
        path: String,
        concurrency: Concurrency,
        max_retries: Option<usize>,
        worker_count: Option<usize>,
    },
    String {
        concurrency: Concurrency,
        max_retries: Option<usize>,
        worker_count: Option<usize>,
        capacity: Option<usize>,
    },
    Vector {
        concurrency: Concurrency,
        max_retries: Option<usize>,
        worker_count: Option<usize>,
        capacity: Option<usize>,
    },
    Loki {
        url: String,
        app: String,
        job: String,
        env: String,
        basic_auth: Option<BasicAuth>,
        bearer_auth: Option<String>,
        connection_timeout: FlexibleDuration,
        request_timeout: FlexibleDuration,
        max_retries: usize,
        worker_count: usize,
    },
    CloudWatchEnv {
        log_group: String,
    },
    CloudWatchConfig {
        access_key_id: String,
        access_key_secret: String,
        session_token: Option<String>,
        expires_in: Option<Timestamp>,
        log_group: String,
        region: String,
    },
    CloudWatchCout {
        concurrency: Concurrency,
        max_retries: Option<usize>,
        worker_count: Option<usize>,
    },
    DisabledFeature {
        feature: String,
    },
}
Expand description

Represents the destination and configuration for a logging channel.

This enum defines where log entries are sent and how they are processed. It supports various outputs ranging from standard streams to cloud-based collectors like Grafana Loki.

See LogManager (represents a channel).

Variants§

§

Silent

A “black hole” destination. All logs sent to this channel are silently discarded.

See: SilentLogger.

§

StdOut

Standard Output (stdout). Logs are printed directly to the terminal’s standard output stream.

Fields

§concurrency: Concurrency

The execution strategy: Concurrency::Sync for immediate writes, or Concurrency::Async for background-threaded logging.

§max_retries: Option<usize>

Optional override for the maximum number of write retries. If None, the factory default (usually 3) is used.

§worker_count: Option<usize>

Optional override for the number of background worker threads. If None, the factory default (usually 1) is used. Note: A value of 1 is recommended to prevent interlaced output.

§

StdErr

Standard Error (stderr). Logs are printed to the terminal’s standard error stream, typically used for diagnostics or errors.

Fields

§concurrency: Concurrency

The execution strategy: Concurrency::Sync for immediate writes, or Concurrency::Async for background-threaded logging.

§max_retries: Option<usize>

Optional override for the maximum number of write retries. If None, the factory default (usually 3) is used.

§worker_count: Option<usize>

Optional override for the number of background worker threads. If None, the factory default (usually 1) is used. Note: A value of 1 is recommended to prevent interlaced output.

§

File

Unbuffered File Output. Logs are written directly to a file on disk. Each write is typically immediate, ensuring data integrity at the cost of higher I/O overhead.

Fields

§path: String

Path to the file where to dump the log.

§concurrency: Concurrency

The execution strategy: Concurrency::Sync for immediate writes, or Concurrency::Async for background-threaded logging.

§max_retries: Option<usize>

Optional override for the maximum number of write retries. If None, the factory default (usually 3) is used.

§worker_count: Option<usize>

Optional override for the number of background worker threads. If None, the factory default (usually 1) is used. Note: A value of 1 is recommended to prevent interlaced output.

§

BufferedFile

Performance-Optimized Buffered File Output. Logs are accumulated in a memory buffer before being flushed to disk.

§⚠️ Warning

Use with caution. Because logs are held in memory, a sudden application crash or panic may result in the loss of the most recent log entries.

Unbuffered File Output. Logs are written directly to a file on disk. Each write is typically immediate, ensuring data integrity at the cost of higher I/O overhead.

Fields

§path: String

Path to the file where to dump the log.

§concurrency: Concurrency

The execution strategy: Concurrency::Sync for immediate writes, or Concurrency::Async for background-threaded logging.

§max_retries: Option<usize>

Optional override for the maximum number of write retries. If None, the factory default (usually 3) is used.

§worker_count: Option<usize>

Optional override for the number of background worker threads. If None, the factory default (usually 1) is used. Note: A value of 1 is recommended to prevent interlaced output.

§

String

Memory Buffer. Captures logs into an internal string buffer, useful for testing or displaying logs within an application UI.

Fields

§concurrency: Concurrency

The execution strategy: Concurrency::Sync for immediate writes, or Concurrency::Async for background-threaded logging.

§max_retries: Option<usize>

Optional override for the maximum number of write retries. If None, the factory default (usually 3) is used.

§worker_count: Option<usize>

Optional override for the number of background worker threads. If None, the factory default (usually 1) is used. Note: A value of 1 is recommended to prevent interlaced output.

§capacity: Option<usize>

String capacity

§

Vector

Memory Buffer (vector). Captures logs into an internal vector, useful for testing.

Fields

§concurrency: Concurrency

The execution strategy: Concurrency::Sync for immediate writes, or Concurrency::Async for background-threaded logging.

§max_retries: Option<usize>

Optional override for the maximum number of write retries. If None, the factory default (usually 3) is used.

§worker_count: Option<usize>

Optional override for the number of background worker threads. If None, the factory default (usually 1) is used. Note: A value of 1 is recommended to prevent interlaced output.

§capacity: Option<usize>

Vector capacity

§

Loki

Grafana Loki Integration. Pushes logs to a remote Loki instance via HTTP/HTTPS.

This variant is only available when the loki feature is enabled.

Fields

§url: String

The full HTTP/HTTPS endpoint for the Loki push API (e.g., https://logs-prod-us-central1.grafana.net/loki/api/v1/push).

§app: String

The name of the application. This becomes a static label used for filtering logs in Grafana.

§job: String

The job name associated with the process. Useful for distinguishing between different instances of the same application.

§env: String

The deployment environment (e.g., “production”, “staging”, “development”). Helps isolate logs across different stages of the lifecycle.

§basic_auth: Option<BasicAuth>

Optional credentials for Basic Authentication.

§bearer_auth: Option<String>

Optional Bearer token for API authentication (e.g., for Grafana Cloud).

§connection_timeout: FlexibleDuration

The maximum time allowed to establish a connection to the Loki server.

§request_timeout: FlexibleDuration

The maximum time allowed for a single push request to complete.

§max_retries: usize

How many times a failed push should be retried before falling back. This is handled by the internal dispatch logic.

§worker_count: usize

The number of background worker threads dedicated to pushing logs. Higher counts increase throughput but consume more network resources.

§

CloudWatchEnv

AWS Cloudwatch Integration. Pushes logs to a remote Cloudwatch Integration instance via AWS SDK.

This variant is only available when the aws feature is enabled.

Fields

§log_group: String

Log group for the cloudwatch service. The config is loaded from ENV.

§

CloudWatchConfig

AWS Cloudwatch Integration. Pushes logs to a remote Cloudwatch Integration instance via AWS SDK.

This variant is only available when the aws feature is enabled.

Fields

§access_key_id: String

AWS Access Key ID used for authentication.

§access_key_secret: String

AWS Secret Access Key. This field is sensitive and hidden in Debug logs.

§session_token: Option<String>

Optional session token for temporary credentials (STS).

§expires_in: Option<Timestamp>

Optional expiration timestamp for the credentials in seconds.

§log_group: String

The name of the CloudWatch Log Group where logs will be sent.

§region: String

The AWS Region (e.g., “us-east-1”).

§

CloudWatchCout

AWS CloudWatch (via Standard Output).

Formats logs as single-line JSON objects and prints them to stdout. This is the preferred method for AWS Lambda, ECS (with awslogs driver), and Fargate, as it avoids the overhead of the AWS SDK while maintaining structured logs.

Fields

§concurrency: Concurrency

The execution strategy: Concurrency::Sync for immediate writes, or Concurrency::Async for background-threaded logging.

§max_retries: Option<usize>

Optional override for the maximum number of write retries. If None, the factory default (usually 3) is used.

§worker_count: Option<usize>

Optional override for the number of background worker threads. If None, the factory default (usually 1) is used. Note: A value of 1 is recommended to prevent interlaced output.

§

DisabledFeature

Placeholder for missing functionality. Used when a configuration specifies a model (like loki) but the required crate feature was not enabled at compile time.

Fields

§feature: String

The name of the feature that is currently missing.

Implementations§

Source§

impl Entry

Source

pub fn silent() -> Self

Creates a configuration for a silent logger that discards all input.

Useful as a placeholder or for completely disabling output in specific environments.

Source

pub fn stdout(concurrency: Concurrency) -> Self

Configures logging to the Standard Output stream (stdout).

This is the primary target for CLI applications and containerized services.

Source

pub fn stderr(concurrency: Concurrency) -> Self

Configures logging to the Standard Error stream (stderr).

Recommended for diagnostic messages to keep the main stdout stream clean for data.

Source

pub fn string(concurrency: Concurrency) -> Self

Configures an in-memory string buffer for captured logs.

Useful for small-scale log capturing where a full Vector of messages is not required.

Source

pub fn file(concurrency: Concurrency, path: String) -> Self

Configures a raw file logger at the specified path.

Opens the file in append mode. Ensure the process has appropriate write permissions.

Source

pub fn buffered_file(concurrency: Concurrency, path: String) -> Self

Configures a buffered file logger at the specified path.

Wraps the file in a buffer to reduce the frequency of underlying system calls, significantly improving performance during high-volume bursts.

Source

pub fn vector(concurrency: Concurrency) -> Self

Configures a logger that captures structured Message objects in a Vec.

This is the “gold standard” for unit testing, allowing for precise assertions on log levels and contents.

Source

pub fn loki(config: LokiConfig) -> Self

Integrates a Grafana Loki configuration into the entry list.

This converts a high-level LokiConfig into the flat enum representation.

Source

pub fn cloudwatch_config(config: CloudWatchConfig) -> Self

Configures Amazon CloudWatch using explicit credentials.

Use this when credentials are provided manually or via a secret manager.

Source

pub fn cloudwatch_env(log_group: String) -> Self

Configures Amazon CloudWatch using credentials sourced from the environment.

Standard AWS environment variables (AWS_ACCESS_KEY_ID, etc.) will be used automatically.

Source

pub fn cloudwatch_cout(concurrency: Concurrency) -> Self

Configures a CloudWatch-formatted logger that writes to stdout.

This allows logs to be formatted for AWS CloudWatch even if they are being emitted to a local terminal or captured by a separate log agent.

Source§

impl Entry

Source

pub fn get_concurrency(&self) -> Option<Concurrency>

Returns the concurrency strategy if the variant supports one.

Returns None for variants like Silent where execution strategy is irrelevant.

Source

pub fn get_capacity(&self) -> Option<usize>

Returns the configured capacity if the variant supports pre-allocation.

Source

pub fn get_worker_count(&self) -> Option<usize>

Returns the number of worker threads configured for this entry.

Source

pub fn get_max_retries(&self) -> Option<usize>

Returns the maximum retry attempts configured for this entry.

Source

pub fn concurrency(self, concurrency: Concurrency) -> Self

Sets the concurrency strategy for this entry.

Source

pub fn capacity(self, capacity: usize) -> Self

Sets the pre-allocation capacity for variants that support it (String, Vector).

Source

pub fn worker_count(self, worker_count: usize) -> Self

Sets the background worker count for this entry.

Source

pub fn max_retries(self, max_retries: usize) -> Self

Sets the maximum number of retry attempts for this entry.

Source

pub fn build_loki_config(self) -> Option<LokiConfig>

Attempts to extract and build a LokiConfig from this entry.

Source

pub fn build_cloudwatch_config(self) -> Option<CloudWatchConfig>

Attempts to extract and build a CloudWatchConfig from this entry.

Trait Implementations§

Source§

impl Clone for Entry

Source§

fn clone(&self) -> Entry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Entry

Source§

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

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

impl<'de> Deserialize<'de> for Entry

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Entry

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Entry

§

impl RefUnwindSafe for Entry

§

impl Send for Entry

§

impl Sync for Entry

§

impl Unpin for Entry

§

impl UnwindSafe for Entry

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,