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.
- See:
service::write::Cout - See:
logger::Direct - See:
logger::Queued
Fields
concurrency: ConcurrencyThe execution strategy: Concurrency::Sync for immediate writes,
or Concurrency::Async for background-threaded logging.
StdErr
Standard Error (stderr). Logs are printed to the terminal’s standard error stream, typically used for diagnostics or errors.
- See:
service::write::Cerr. - See:
logger::Direct - See:
logger::Queued
Fields
concurrency: ConcurrencyThe execution strategy: Concurrency::Sync for immediate writes,
or Concurrency::Async for background-threaded logging.
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.
- See:
service::write::File. - See:
logger::Direct - See:
logger::Queued
Fields
concurrency: ConcurrencyThe execution strategy: Concurrency::Sync for immediate writes,
or Concurrency::Async for background-threaded logging.
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.
- See:
service::write::BufferedFile. - See:
service::IoWrite. - See:
std::fs::File - See:
std::io::BufWriter - See:
logger::Direct - See:
logger::Queued
Fields
concurrency: ConcurrencyThe execution strategy: Concurrency::Sync for immediate writes,
or Concurrency::Async for background-threaded logging.
String
Memory Buffer. Captures logs into an internal string buffer, useful for testing or displaying logs within an application UI.
- See:
service::write::StringFmt. - See:
logger::Direct - See:
logger::Queued
Fields
concurrency: ConcurrencyThe 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.
Vector
Memory Buffer (vector). Captures logs into an internal vector, useful for testing.
- See:
service::Vector. - See:
logger::Direct - See:
logger::Queued
Fields
concurrency: ConcurrencyThe 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.
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.
- See:
LokiLogger. - See:
LokiService. - See:
LokiConfig. - See:
logger::Direct - See:
logger::Queued
Fields
url: StringThe full HTTP/HTTPS endpoint for the Loki push API
(e.g., https://logs-prod-us-central1.grafana.net/loki/api/v1/push).
app: StringThe name of the application. This becomes a static label used for filtering logs in Grafana.
job: StringThe job name associated with the process. Useful for distinguishing between different instances of the same application.
env: StringThe deployment environment (e.g., “production”, “staging”, “development”). Helps isolate logs across different stages of the lifecycle.
connection_timeout: FlexibleDurationThe maximum time allowed to establish a connection to the Loki server.
request_timeout: FlexibleDurationThe maximum time allowed for a single push request to complete.
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.
- See:
CloudwatchLogger. - See:
CloudwatchService. - See:
CloudwatchConfig. - See:
logger::Direct - See:
logger::Queued
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.
- See:
CloudwatchLogger. - See:
CloudwatchService. - See:
CloudwatchConfig. - See:
logger::Direct - See:
logger::Queued
Fields
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.
- See:
CloudWatchCout. - See:
CloudWatchCoutMessageFormatter. - See:
logger::Direct - See:
logger::Queued
Fields
concurrency: ConcurrencyThe execution strategy: Concurrency::Sync for immediate writes,
or Concurrency::Async for background-threaded logging.
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.
Implementations§
Source§impl Entry
impl Entry
Sourcepub fn silent() -> Self
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.
Sourcepub fn stdout(concurrency: Concurrency) -> Self
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.
Sourcepub fn stderr(concurrency: Concurrency) -> Self
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.
Sourcepub fn string(concurrency: Concurrency) -> Self
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.
Sourcepub fn file(concurrency: Concurrency, path: String) -> Self
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.
Sourcepub fn buffered_file(concurrency: Concurrency, path: String) -> Self
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.
Sourcepub fn vector(concurrency: Concurrency) -> Self
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.
Sourcepub fn loki(config: LokiConfig) -> Self
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.
Sourcepub fn cloudwatch_config(config: CloudWatchConfig) -> Self
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.
Sourcepub fn cloudwatch_env(log_group: String) -> Self
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.
Sourcepub fn cloudwatch_cout(concurrency: Concurrency) -> Self
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
impl Entry
Sourcepub fn get_concurrency(&self) -> Option<Concurrency>
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.
Sourcepub fn get_capacity(&self) -> Option<usize>
pub fn get_capacity(&self) -> Option<usize>
Returns the configured capacity if the variant supports pre-allocation.
Sourcepub fn get_worker_count(&self) -> Option<usize>
pub fn get_worker_count(&self) -> Option<usize>
Returns the number of worker threads configured for this entry.
Sourcepub fn get_max_retries(&self) -> Option<usize>
pub fn get_max_retries(&self) -> Option<usize>
Returns the maximum retry attempts configured for this entry.
Sourcepub fn concurrency(self, concurrency: Concurrency) -> Self
pub fn concurrency(self, concurrency: Concurrency) -> Self
Sets the concurrency strategy for this entry.
Sourcepub fn capacity(self, capacity: usize) -> Self
pub fn capacity(self, capacity: usize) -> Self
Sets the pre-allocation capacity for variants that support it (String, Vector).
Sourcepub fn worker_count(self, worker_count: usize) -> Self
pub fn worker_count(self, worker_count: usize) -> Self
Sets the background worker count for this entry.
Sourcepub fn max_retries(self, max_retries: usize) -> Self
pub fn max_retries(self, max_retries: usize) -> Self
Sets the maximum number of retry attempts for this entry.
Sourcepub fn build_loki_config(self) -> Option<LokiConfig>
pub fn build_loki_config(self) -> Option<LokiConfig>
Attempts to extract and build a LokiConfig from this entry.
Sourcepub fn build_cloudwatch_config(self) -> Option<CloudWatchConfig>
pub fn build_cloudwatch_config(self) -> Option<CloudWatchConfig>
Attempts to extract and build a CloudWatchConfig from this entry.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Entry
impl<'de> Deserialize<'de> for Entry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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