use std::{borrow::Cow, sync::Arc};
use crate::{logs::LogRecord, InstrumentationLibrary, KeyValue};
#[cfg(feature = "logs_level_enabled")]
use super::Severity;
pub trait Logger {
fn emit(&self, record: LogRecord);
#[cfg(feature = "logs_level_enabled")]
fn event_enabled(&self, level: Severity, target: &str) -> bool;
}
pub trait LoggerProvider {
type Logger: Logger;
fn versioned_logger(
&self,
name: impl Into<Cow<'static, str>>,
version: Option<Cow<'static, str>>,
schema_url: Option<Cow<'static, str>>,
attributes: Option<Vec<KeyValue>>,
) -> Self::Logger {
self.library_logger(Arc::new(InstrumentationLibrary::new(
name, version, schema_url, attributes,
)))
}
fn library_logger(&self, library: Arc<InstrumentationLibrary>) -> Self::Logger;
fn logger(&self, name: impl Into<Cow<'static, str>>) -> Self::Logger {
self.versioned_logger(name, None, None, None)
}
}