pub trait LogRecord {
// Required methods
fn to_json(&self) -> String;
fn get_timestamp(&self) -> DateTime<Utc>;
}
Expand description
Trait for types that can be serialized to JSON and have a timestamp
This trait is used by ServerLogEntry
to convert the log entry to JSON
and get the timestamp of the log entry
This trait is implemented by ServerLogEntry
§Example
use rustfs_obs::LogRecord;
use chrono::{DateTime, Utc};
use rustfs_obs::ServerLogEntry;
use tracing_core::Level;
let log_entry = ServerLogEntry::new(Level::INFO, "api_handler".to_string());
let json = log_entry.to_json();
let timestamp = log_entry.get_timestamp();