use crate::{log_debug, log_error, log_info, log_trace, log_warning};
pub fn error(args: std::fmt::Arguments) {
log_error("{}", args);
}
pub fn warn(args: std::fmt::Arguments) {
log_warning("{}", args);
}
pub fn info(args: std::fmt::Arguments) {
log_info("{}", args);
}
pub fn debug(args: std::fmt::Arguments) {
log_debug("{}", args);
}
pub fn trace(args: std::fmt::Arguments) {
log_trace("{}", args);
}
#[macro_export]
macro_rules! error {
($($arg:tt)+) => {
$crate::logging::wrapper::error(format_args!($($arg)+))
};
}
#[macro_export]
macro_rules! warn {
($($arg:tt)+) => {
$crate::logging::wrapper::warn(format_args!($($arg)+))
};
}
#[macro_export]
macro_rules! info {
($($arg:tt)+) => {
$crate::logging::wrapper::info(format_args!($($arg)+))
};
}
#[macro_export]
macro_rules! debug {
($($arg:tt)+) => {
$crate::logging::wrapper::debug(format_args!($($arg)+))
};
}
#[macro_export]
macro_rules! trace {
($($arg:tt)+) => {
$crate::logging::wrapper::trace(format_args!($($arg)+))
};
}
#[macro_export]
macro_rules! error_fmt {
($context:expr, $($arg:tt)+) => {
if $crate::logging::is_structured_logging() {
slog_scope::error!("{}", format_args!($($arg)+); "context" => $context);
} else {
crate::error!("{}: {}", $context, format_args!($($arg)+));
}
};
}
#[macro_export]
macro_rules! warn_fmt {
($context:expr, $($arg:tt)+) => {
if $crate::logging::is_structured_logging() {
slog_scope::warn!("{}", format_args!($($arg)+); "context" => $context);
} else {
crate::warn!("{}: {}", $context, format_args!($($arg)+));
}
};
}
#[macro_export]
macro_rules! info_fmt {
($context:expr, $($arg:tt)+) => {
if $crate::logging::is_structured_logging() {
slog_scope::info!("{}", format_args!($($arg)+); "context" => $context);
} else {
crate::info!("{}: {}", $context, format_args!($($arg)+));
}
};
}
#[macro_export]
macro_rules! debug_fmt {
($context:expr, $($arg:tt)+) => {
if $crate::logging::is_structured_logging() {
slog_scope::debug!("{}", format_args!($($arg)+); "context" => $context);
} else {
crate::debug!("{}: {}", $context, format_args!($($arg)+));
}
};
}
#[macro_export]
macro_rules! trace_fmt {
($context:expr, $($arg:tt)+) => {
if $crate::logging::is_structured_logging() {
slog_scope::trace!("{}", format_args!($($arg)+); "context" => $context);
} else {
crate::trace!("{}: {}", $context, format_args!($($arg)+));
}
};
}