Trait HandlerTrait

Source
pub trait HandlerTrait:
    Display
    + Send
    + Sync {
    // Required methods
    fn create(name: &str) -> Result<Self, Error>
       where Self: Sized;
    fn close(&mut self);
    fn flush(&mut self);
    fn get_log(&self) -> String;
    fn get_formatter(&self) -> Formatter;
    fn is_open(&self) -> bool;
    fn publish(&mut self, log_entry: &LogEntry);
    fn set_formatter(&mut self, formatter: Formatter);
}
Expand description

Provides common methods required for all handlers.

Required Methods§

Source

fn create(name: &str) -> Result<Self, Error>
where Self: Sized,

Create a new handler instance.

§Parameters
  • name - Can be used as needed.
Source

fn close(&mut self)

Close the Handler and free all associated resources.

The close method will perform a flush and then close the Handler. After close has been called, this Handler should no longer be used. Method calls will be silently ignored.

Source

fn flush(&mut self)

Flush any buffered output.

Source

fn get_log(&self) -> String

Return a copy of the internal buffer as a String.

Source

fn get_formatter(&self) -> Formatter

Return the Formatter for this Handler.

Source

fn is_open(&self) -> bool

Check status of this handler.

Source

fn publish(&mut self, log_entry: &LogEntry)

Publish a LogEntry.

The logging request was made initially to a Logger object, which initialized the LogEntry and forwarded it here.

The Handler is responsible for formatting the message, when and if necessary.

§Parameters
  • log_entry - The LogEntry to be published.
Source

fn set_formatter(&mut self, formatter: Formatter)

Set a Formatter.

§Parameters
  • formatter The Formatter to use.

Implementors§