Skip to main content

simple_custom_logger

Function simple_custom_logger 

Source
pub fn simple_custom_logger<F>(log_fn: F) -> impl Logger
where F: Fn(&str, &str, &LogInfo) + Send + Sync + Clone + 'static,
Expand description

Creates a simple custom logger that uses a single closure for all log levels.

This is a convenience function for cases where you want the same handling for all log levels. The closure receives the log level as a string, the message, and the log info.

§Arguments

  • log_fn - Closure called for all log messages. Receives (level, message, info).

§Example

use durable_execution_sdk::context::{simple_custom_logger, LogInfo};
use std::sync::Arc;

// Create a simple logger that prints all messages with their level
let logger = simple_custom_logger(|level, msg, info| {
    println!("[{}] {}: {:?}", level, msg, info);
});

// Use with Arc for sharing across contexts
let shared_logger = Arc::new(logger);