Skip to main content

Logger

Struct Logger 

Source
pub struct Logger { /* private fields */ }
Available on crate feature logging only.
Expand description

Logging utility for dnet transports.

Implementations§

Source§

impl Logger

Source

pub fn new<T>() -> Self
where T: Logging,

Create new logger for transport.

Source

pub fn new_for_already_named<T>(transport_name: &str) -> Self
where T: Logging,

Create new logger for transport that already has a name.

Usually dnet transports don’t have names, but when they do you may use this constructor to make transport’s logical name the same as the one used for logging purposes.

Note that logging name may still be changed later by the transport user and at that point logical name and logging name may be different.

Source

pub fn log_open_success(&self)

Log that the transport was opened successfully.

Note: not all transports emit an “open” event — transports that do not wait for an explicit open should skip calling this.

Source

pub fn log_open_failure(&self, error: impl Error)

Log that opening the transport failed.

Useful for transports that report an explicit open failure to the application. Transports that don’t wait for opening can ignore this.

Source

pub fn log_ready<S, F>(&self, result: &Poll<Result<S, F>>)
where F: Error,

Helper method for logging readiness based on result.

See log_ready_success and log_ready_failure for more details.

Source

pub fn log_ready_success(&self)

Log that the transport is ready for sending messages.

Currently this does not log anything to keep the log less verbose, but it may be changed in the future.

Source

pub fn log_ready_failure(&self, error: impl Error)

Log that the transport failed to become ready for sending messages.

Source

pub fn log_message_staging<O, S, F>(&self, result: &Result<S, F>)
where F: Error,

Helper method for logging message staging based on result.

See log_message_staging_success and log_message_staging_failure for more info.

Source

pub fn log_message_staging_success<O>(&self)

Log successful staging of an outgoing message for sending.

Used by transports that stage outgoing messages by putting them into buffer before encoding and sending. Not every transport stages messages before sending - this method may be unused.

Source

pub fn log_message_staging_failure(&self, error: impl Error)

Log failure while staging an outgoing message for sending.

Used by transports that stage outgoing messages by putting them into buffer before encoding and sending. Not every transport stages messages before sending - this method may be unused.

Source

pub fn log_message_preparation<O, S, F>( &self, send_buffer_len_before: usize, send_buffer_len_after: usize, result: &Result<S, F>, )
where F: Error,

Helper method for logging message preparation based on result.

See log_message_preparation_success and log_message_preparation_failure for more info.

Source

pub fn log_message_preparation_success<O>(&self, size: Option<usize>)

Log successful preparation of an outgoing message.

Used by transports that buffer or prepare messages before sending (flushing). Not every transport buffers messages before sending.

Source

pub fn log_message_preparation_failure(&self, error: impl Error)

Log failure while preparing an outgoing message.

Used by buffered transports that perform message preparation steps before sending (flushing); may be unused by simpler transports.

Source

pub fn log_sending<O, F>(&self, result: &Result<(), F>, size: Option<usize>)
where F: Error,

Helper method for logging message sending based on result.

See log_sending_success and log_sending_failure for more info.

Source

pub fn log_sending_success<O>(&self, size: Option<usize>)

Log that a message was sent successfully.

Source

pub fn log_sending_failure(&self, error: impl Error)

Log that sending a message failed.

Source

pub fn log_message_arrived_unknown(&self, size: Option<usize>)

Log that a message data arrived (was received and enqueued).

This is used by transports that receive messages data in the background and place them into a buffer for later deserialization and consumption; not all transports will use arrival logs.

It is called “unknown” because at this point we don’t know if message deserialization will succeed or not.

Source

pub fn log_message_arrived_success<I>(&self, _item: &I, size: Option<usize>)

Log that a message arrived (was received and enqueued).

This is used by transports that receive messages in the background and place them into a buffer for later consumption; not all transports will use arrival logs.

Source

pub fn log_message_arrived_failure(&self, error: impl Error)

Log failure during background arrival/enqueue of a received message.

Relevant for transports that buffer incoming messages in the background; may be unused by transports that only receive message while precessing next method.

Source

pub fn log_receiving<I, F>( &self, result: &Poll<Option<Result<I, F>>>, message_length: Option<usize>, )
where F: Error,

Helper method for logging receiving based on result.

See log_receiving_success, log_receiving_failure and log_remote_closed for more info.

Source

pub fn log_receiving_success<I>(&self, _item: &I, size: Option<usize>)

Log that a message was successfully received.

Source

pub fn log_receiving_failure(&self, error: impl Error)

Log that receiving a message failed.

Source

pub fn log_receive_from_void(&self)

Log that an attempt to receive from a Void transport was made.

Source

pub fn log_flush<S, F>(&self, result: &Poll<Result<S, F>>)
where F: Error,

Helper method for logging flush.

See log_flush_success and log_flush_failure for more info.

Source

pub fn log_flush_success(&self)

Log that buffered messages were flushed successfully.

Source

pub fn log_flush_failure(&self, error: impl Error)

Log that flushing buffered messages failed.

Source

pub fn log_close<S, F>(&self, result: &Poll<Result<S, F>>)
where F: Error,

Helper method for logging closing of the transport based on result.

See log_closed_success, log_closed_failure for more info.

Source

pub fn log_closed_success(&self)

Log that the transport was closed locally successfully.

Source

pub fn log_closed_failure(&self, error: impl Error)

Log that closing the transport locally failed.

Source

pub fn log_remote_closed(&self)

Log that the remote peer closed the transport.

Source

pub fn log_incoming_filtered_out<I>(&self)

Log that an incoming message was filtered out.

Source

pub fn log_outgoing_filtered_out<I>(&self)

Log that an outgoing message was filtered out.

Source

pub fn set_transport_name(&mut self, name: Option<String>)

Set transport name for logging purposes.

Source

pub fn get_transport_name(&self) -> Option<&str>

Get transport name for logging purposes.

Source

pub fn enable(&mut self)

Enable logging.

Source

pub fn disable(&mut self)

Disable logging.

Source

pub fn is_enabled(&self) -> bool

Is logging enabled.

Source

pub fn override_kind<T>(&mut self)
where T: Logging,

Override existing logger kind with another transport type kind.

Source

pub fn override_kind_with_str(&mut self, kind: &str)

Override existing logger kind with provided string.

Source

pub fn override_kind_buffered<T>(&mut self)
where T: Logging,

Override existing logger kind with another (buffered) transport type kind.

Source

pub fn override_kind_part<T>(&mut self, variant: usize)
where T: Logging,

Override existing logger kind with another (part) transport type kind.

Source

pub fn span(&self) -> Span

Create a tracing span for this transport.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more