Function log_with_context

Source
pub async fn log_with_context(
    message: &str,
    source: &str,
    level: Level,
    request_id: Option<String>,
    user_id: Option<String>,
    fields: Vec<(String, String)>,
) -> Result<(), GlobalError>
Expand description

Log with context information This function logs messages with context information.

§Parameters

  • message: Message to be logged
  • source: Source of the log
  • level: Log level
  • request_id: Request ID
  • user_id: User ID
  • fields: Additional fields

§Returns

Result indicating whether the operation was successful

§Example

use tracing_core::Level;
use rustfs_obs::log_with_context;

async fn example() {
   let _ = log_with_context("This is an information message", "example", Level::INFO, Some("req-12345".to_string()), Some("user-6789".to_string()), vec![("endpoint".to_string(), "/api/v1/data".to_string())]).await;
}