use std::io::Write;
pub mod backend;
pub mod rfc3164;
pub mod rfc5424;
use crate::errors::Result;
use crate::format::LogFormat;
pub use self::backend::LoggerBackend;
pub use self::rfc3164::Logger3164;
pub use self::rfc5424::Logger5424;
pub struct Logger<Backend: Write, Formatter> {
pub formatter: Formatter,
pub backend: Backend,
}
impl<W: Write, F> Logger<W, F> {
pub fn new(backend: W, formatter: F) -> Self {
Logger { backend, formatter }
}
pub fn emerg<T>(&mut self, message: T) -> Result<()>
where
F: LogFormat<T>,
{
self.formatter.emerg(&mut self.backend, message)
}
pub fn alert<T>(&mut self, message: T) -> Result<()>
where
F: LogFormat<T>,
{
self.formatter.alert(&mut self.backend, message)
}
pub fn crit<T>(&mut self, message: T) -> Result<()>
where
F: LogFormat<T>,
{
self.formatter.crit(&mut self.backend, message)
}
pub fn err<T>(&mut self, message: T) -> Result<()>
where
F: LogFormat<T>,
{
self.formatter.err(&mut self.backend, message)
}
pub fn warning<T>(&mut self, message: T) -> Result<()>
where
F: LogFormat<T>,
{
self.formatter.warning(&mut self.backend, message)
}
pub fn notice<T>(&mut self, message: T) -> Result<()>
where
F: LogFormat<T>,
{
self.formatter.notice(&mut self.backend, message)
}
pub fn info<T>(&mut self, message: T) -> Result<()>
where
F: LogFormat<T>,
{
self.formatter.info(&mut self.backend, message)
}
pub fn debug<T>(&mut self, message: T) -> Result<()>
where
F: LogFormat<T>,
{
self.formatter.debug(&mut self.backend, message)
}
}