format

Function format 

Source
pub fn format(buf: &mut impl Write, record: &Record<'_>) -> Result<()>
Expand description

Writes an ECS log line to the buf.

You may pass this format function to env_logger::Builder::format when building a custom logger.

ยงExample

use log::info;

// Initialize custom logger
env_logger::builder()
    .parse_filters("info,my_app=debug") // Set filters
    .format(ecs_logger::format) // Configure ECS logger
    .target(env_logger::Target::Stdout) // Write to stdout
    .init();

info!("Hello {}!", "world");