mod settings;
mod structured_message;
mod terminal_logger;
use std::collections::BTreeMap;
use log::{self, Level, LevelFilter, Log, SetLoggerError};
pub use self::terminal_logger::TerminalLogger;
pub use settings::{Settings, Style};
#[doc(hidden)]
pub const PAYLOAD_KEY: &str = "payload=";
pub(crate) const METRIC_METADATA_TARGET: &str = "METRIC";
pub(crate) const CASPER_METADATA_TARGET: &str = "casper_";
pub(crate) const MESSAGE_TEMPLATE_KEY: &str = "message_template";
pub(crate) const DEFAULT_MESSAGE_TEMPLATE: &str = "{message}";
pub(crate) const DEFAULT_MESSAGE_KEY: &str = "message";
pub fn initialize(settings: Settings) -> Result<(), SetLoggerError> {
let logger = Box::new(TerminalLogger::new(&settings));
initialize_with_logger(logger, settings)
}
#[doc(hidden)]
pub fn initialize_with_logger(
logger: Box<dyn Log>,
settings: Settings,
) -> Result<(), SetLoggerError> {
if settings.max_level() == LevelFilter::Off && !settings.enable_metrics() {
return Ok(());
}
log::set_boxed_logger(logger)?;
log::set_max_level(settings.max_level());
Ok(())
}
#[inline]
pub fn log_details(
_log_level: Level,
_message_format: String,
_properties: BTreeMap<&str, String>,
) {
}
pub fn log_host_function_metrics(_host_function: &str, _properties: BTreeMap<&str, String>) {
}