Skip to main content

init_logging_full

Function init_logging_full 

Source
pub fn init_logging_full(setup: LoggingSetup<'_>) -> LoggingResult<LoggingGuard>
Expand description

Enhanced logging init with all options including OTLP export.

Layers the subscriber stack as follows:

  1. EnvFilter — base level + optional per-module overrides
  2. Optional SamplingLayer — rate-based log sampling
  3. Format layer (JSON or console)
  4. Optional OtlpProvider layer — bridges events to OTel Logs SDK

The returned LoggingGuard must be held for the lifetime of the service. When dropped it restores the previous subscriber and (when OTLP is enabled) shuts down the provider, flushing pending logs.

§Errors

Returns an error if the OTLP provider cannot be created (e.g. invalid endpoint or transport failure), or if a custom masking regex pattern is invalid.