You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
725 B

//! Extra logging types for log files and such
use super::*;
use generational_arena::Index;
use mopa::*;
use std::marker::{Sync, Send};
/// A logging hook
pub trait Hook: Sync + Send + Any
{
/// The name of this hook object
fn name(&self) -> &str {"(unnamed)"}
/// Fired when hook is added
fn initialise(&mut self, _idx: &Index) {}
/// Fired when `println` is called
fn println(&mut self, level: &dyn AsLevel, what: &dyn Display, trace: &Trace) -> io::Result<()>;
/// Fired when hook is removed
fn finalise(&mut self, _idx: Index) {}
}
mopafy!(Hook);
impl std::fmt::Debug for dyn Hook
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{
write!(f, "<opaque type>")
}
}