use std::borrow::Cow;
use crate::{LogValue, records::LogRecords};
#[derive(Debug, Default, Clone)]
pub struct LogContext {
pub local: LogRecords,
pub inherited: LogRecords,
}
impl LogContext {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn with_local_record(
mut self,
key: impl Into<Cow<'static, str>>,
value: impl Into<LogValue>,
) -> Self {
self.local = self.local.field(key, value);
self
}
#[must_use]
pub fn with_inherited_record(
mut self,
key: impl Into<Cow<'static, str>>,
value: impl Into<LogValue>,
) -> Self {
self.inherited = self.inherited.field(key, value);
self
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.local.is_empty() && self.inherited.is_empty()
}
}