use crate::WaitGroup;
use std::time::SystemTime;
pub trait LogAppender:Send {
fn do_logs(&mut self, records: &[FastLogRecord]);
}
#[derive(Clone, Debug)]
pub enum Command {
CommandRecord,
CommandExit,
CommandFlush(WaitGroup),
}
impl Command {
pub fn to_i32(&self) -> i32 {
match self {
Command::CommandRecord => 1,
Command::CommandExit => 2,
Command::CommandFlush(_) => 3,
}
}
}
impl PartialEq for Command {
fn eq(&self, other: &Self) -> bool {
self.to_i32().eq(&other.to_i32())
}
}
impl Eq for Command {}
#[derive(Clone, Debug)]
pub struct FastLogRecord {
pub command: Command,
pub level: log::Level,
pub target: String,
pub args: String,
pub module_path: String,
pub file: String,
pub line: Option<u32>,
pub now: SystemTime,
pub formated: String,
}
pub trait RecordFormat: Send + Sync {
fn do_format(&self, arg: &mut FastLogRecord);
}