Struct NetworkHandler

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

A handler that writes log records to a network socket

Implementations§

Source§

impl NetworkHandler

Source

pub fn new(stream: TcpStream, level: LogLevel) -> Self

Source

pub fn with_level(self, level: LogLevel) -> Self

Source

pub fn with_formatter(self, formatter: Formatter) -> Self

Source

pub fn with_colors(self, use_colors: bool) -> Self

Source

pub fn with_pattern(self, pattern: impl Into<String>) -> Self

Source

pub fn with_format<F>(self, format_fn: F) -> Self
where F: Fn(&Record) -> String + Send + Sync + 'static,

Source

pub fn with_filter(self, filter: HandlerFilter) -> Self

Source

pub fn with_batching(self, batch_size: usize) -> Self

Trait Implementations§

Source§

impl Clone for NetworkHandler

Source§

fn clone(&self) -> Self

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 Debug for NetworkHandler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Handler for NetworkHandler

Source§

fn handle(&self, record: &Record) -> Result<(), HandlerError>

Handle a log record
Source§

fn level(&self) -> LogLevel

Get the log level
Source§

fn set_level(&mut self, level: LogLevel)

Set the log level
Source§

fn is_enabled(&self) -> bool

Check if the handler is enabled
Source§

fn set_enabled(&mut self, enabled: bool)

Set whether the handler is enabled
Source§

fn formatter(&self) -> &Formatter

Get the formatter
Source§

fn set_formatter(&mut self, formatter: Formatter)

Set the formatter
Source§

fn set_filter(&mut self, filter: Option<HandlerFilter>)

Set a filter closure for this handler (optional, default: no filter)
Source§

fn filter(&self) -> Option<&HandlerFilter>

Get the filter closure for this handler (optional)
Source§

fn handle_batch(&self, records: &[Record]) -> Result<(), HandlerError>

Handle a batch of log records (optimized implementation)
Source§

fn init(&mut self) -> Result<(), HandlerError>

Lifecycle: initialize the handler
Source§

fn flush(&self) -> Result<(), HandlerError>

Lifecycle: flush the handler
Source§

fn shutdown(&mut self) -> Result<(), HandlerError>

Lifecycle: shutdown the handler

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.