shutdown_logging

Function shutdown_logging 

Source
pub fn shutdown_logging()
Expand description

Gracefully shuts down the logging system and flushes buffered data.

This function ensures all buffered log data is written to disk and, if enabled, exported to OpenTelemetry endpoints before the application exits. It:

  • Flushes the file appender buffer (happens automatically via LOG_GUARD drop)
  • Shuts down OpenTelemetry providers (when otel feature is enabled)
  • Ensures no log data is lost on exit

This function should be called once at application shutdown.

ยงExample

use cadmus_core::logging::{init_logging, shutdown_logging};
use cadmus_core::settings::LoggingSettings;

// At application start
let settings = LoggingSettings::default();
init_logging(&settings)?;

// ... application runs ...

// At application exit
shutdown_logging();