pub fn custom_logger<D, I, W, E>(
debug_fn: D,
info_fn: I,
warn_fn: W,
error_fn: E,
) -> CustomLogger<D, I, W, E>Expand description
Creates a custom logger with user-provided closures for each log level.
This factory function allows users to create custom logging behavior without
implementing the sealed Logger trait directly. Each log level has its own
closure that receives the log message and context information.
§Arguments
debug_fn- Closure called for debug-level messagesinfo_fn- Closure called for info-level messageswarn_fn- Closure called for warning-level messageserror_fn- Closure called for error-level messages
§Example
use durable_execution_sdk::context::{custom_logger, LogInfo};
use std::sync::Arc;
// Create a custom logger that prints to stdout
let logger = custom_logger(
|msg, info| println!("[DEBUG] {}: {:?}", msg, info),
|msg, info| println!("[INFO] {}: {:?}", msg, info),
|msg, info| println!("[WARN] {}: {:?}", msg, info),
|msg, info| println!("[ERROR] {}: {:?}", msg, info),
);
// Use with Arc for sharing across contexts
let shared_logger = Arc::new(logger);