pub mod black_hole;
pub mod file;
pub mod io;
pub mod log_file;
pub mod stderr;
pub mod stdout;
pub mod string;
use ntime;
use std::io as std_io;
use crate::attributes;
use crate::level;
pub type LogDepth = u16;
#[derive(Clone, Debug)]
pub struct LogUpdate {
pub when: ntime::Timestamp,
pub level: level::Level,
pub msg: String,
}
impl LogUpdate {
pub fn blank() -> Self {
Self {
when: ntime::Timestamp::epoch(),
level: level::Level::Panic,
msg: String::from(""),
}
}
pub fn new(now: ntime::Timestamp, level: level::Level, msg: String) -> Self {
Self {
when: now,
level: level,
msg: msg,
}
}
pub fn set_when(&mut self, when: ntime::Timestamp) {
self.when = when;
}
pub fn set_level(&mut self, level: level::Level) {
self.level = level;
}
pub fn set_msg(&mut self, msg: &str) {
self.msg.clear();
self.msg.insert_str(0, msg);
}
}
pub trait Sink {
fn name(&self) -> &str;
fn log(&mut self, update: &LogUpdate, attrs: &attributes::Map) -> std_io::Result<()>;
fn flush(&mut self) -> std_io::Result<()>;
}