Skip to main content

init_logger

Function init_logger 

Source
pub fn init_logger(
    callback: Option<Arc<dyn LogCallback>>,
    level: Option<LogLevel>,
    platform_logger: bool,
)
Expand description

Initialize the SDK logger

This function should be called once before creating any SDK clients. It initializes the tracing infrastructure for the SDK and optionally registers a callback to receive log events.

§Parameters

  • callback: Optional callback to receive SDK log events. Pass None to use only platform loggers (oslog on iOS, logcat on Android).
  • level: Optional minimum log level; events below it are dropped. Defaults to Info if not specified. Can be overridden by the RUST_LOG environment variable at runtime or compile time.
  • platform_logger: Whether the SDK writes log events to the platform logger (oslog on iOS, logcat on Android, stdout elsewhere). Defaults to true. Disable it when callback already forwards events there, otherwise every event is logged twice.

§Example

// Initialize with callback and trace-level logging before creating clients
initLogger(FlightRecorderCallback(), LogLevel.TRACE)
val client = Client(tokenProvider, settings, ManagedSettingsBindingClient())

§Notes

  • This function can only be called once - subsequent calls are ignored
  • If not called explicitly, logging is auto-initialized when first client is created