CallbackManager

Struct CallbackManager 

Source
pub struct CallbackManager { /* private fields */ }
Expand description

Manages all callback types for the logging system.

CallbackManager is thread-safe and allows multiple callbacks of each type to be registered and executed. All callbacks are stored in Arc<RwLock<>> for safe concurrent access.

Implementations§

Source§

impl CallbackManager

Source

pub fn new() -> Self

Creates a new CallbackManager with empty callback collections.

Source

pub fn add_log_callback(&self, callback: LogCallback)

Adds a log callback that will be executed for each log record.

§Arguments
  • callback - Function that takes a LogRecord and returns Result<(), String>
Source

pub fn add_color_callback(&self, callback: ColorCallback)

Adds a color callback for custom color formatting.

§Arguments
  • callback - Function that takes Level and message, returns formatted string
Source

pub fn add_exception_callback(&self, callback: ExceptionCallback)

Adds an exception callback for error handling.

§Arguments
  • callback - Function that takes error message and backtrace
Source

pub fn execute_log_callbacks(&self, record: &LogRecord) -> Vec<String>

Executes all registered log callbacks for a given record.

§Arguments
  • record - The log record to pass to callbacks
§Returns

Vector of error messages from failed callbacks

Source

pub fn execute_color_callbacks( &self, level: Level, message: &str, ) -> Option<String>

Executes the first registered color callback.

§Arguments
  • level - Log level for color selection
  • message - Message text to format
§Returns

Some(formatted_string) if callback exists, None otherwise

Source

pub fn execute_exception_callbacks(&self, error: &str, backtrace: &str)

Executes all registered exception callbacks.

§Arguments
  • error - Error message
  • backtrace - Stack backtrace string
Source

pub fn clear_log_callbacks(&self)

Clears all registered log callbacks.

Source

pub fn clear_color_callbacks(&self)

Clears all registered color callbacks.

Source

pub fn clear_exception_callbacks(&self)

Clears all registered exception callbacks.

Source

pub fn clear_all(&self)

Clears all callbacks of all types.

Trait Implementations§

Source§

impl Clone for CallbackManager

Source§

fn clone(&self) -> CallbackManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for CallbackManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.