encore-dev 2.0.0-beta.13

Rust SDK for Encore applications
Documentation
//! Encore integrations for the standard `log` facade.

/// A direct Encore console logger for the standard [`::log`] facade.
/// Does not initialize the runtime or install globals. The application
/// installs it explicitly and sets its own maximum level:
///
/// ```no_run
/// encore::log::set_logger(encore::telemetry::log::logger())?;
/// encore::log::set_max_level(encore::log::LevelFilter::Info);
/// encore::log::info!(count = 3u64; "finished");
/// encore::telemetry::log::flush();
/// # Ok::<(), encore::log::SetLoggerError>(())
/// ```
///
/// Preserves typed key-values, source metadata and the current native OTel
/// context. Uses the same filters, queue and bounded flush as
/// [`crate::telemetry::tracing::logs_layer`]. Internal tracing diagnostics are
/// excluded; native resource spans and metrics work independently. Choose
/// this direct logger or `tracing_log::LogTracer`, not both.
pub fn logger() -> &'static dyn ::log::Log {
    crate::console_log::logger()
}

/// Waits up to one second for Encore's queued console events to be written.
/// Does not initialize the runtime. Call before exit when using [`logger`] or
/// [`crate::telemetry::tracing::logs_layer`] standalone; runtime shutdown
/// flushes automatically. Queue overflow or blocked output may still lose events.
pub fn flush() {
    crate::console_log::flush();
}