Crate logged_stream

Source
Expand description

This library provides a LoggedStream structure which can be used as a wrapper for underlying IO object which implements Write and Read traits or their asynchronous analogues from tokio library to enable logging of all read and write operations, errors and drop.

LoggedStream structure constructs from four parts:

Structs§

BinaryFormatter
This implementation of BufferFormatter trait formats provided bytes buffer in binary number system.
ChannelLogger
This implementation of Logger trait sends log records (Record) by the sending-half of underlying asynchronous channel. You are able to take receiving-half using take_receiver and take_receiver_unchecked methods.
ConsoleLogger
This implementation of Logger trait writes log record (Record) into console using provided log::Level. Log records with Error kind ignore provided log::Level and always write with log::Level::Error.
DecimalFormatter
This implementation of BufferFormatter trait formats provided bytes buffer in decimal number system.
DefaultFilter
This is default implementation of RecordFilter trait which check method always return true. It should be constructed using Default::default method.
FileLogger
This implementation of Logger trait writes log records (Record) into provided file.
LoggedStream
This is a structure that can be used as a wrapper for underlying IO object which implements Read and Write traits or their asynchronous analogues from tokio library AsyncRead and AsyncWrite to enable logging of all read and write operations, errors and drop.
LowercaseHexadecimalFormatter
This implementation of BufferFormatter trait formats provided bytes buffer in hexdecimal number system.
MemoryStorageLogger
This implementation of Logger trait writes log record (Record) into inner collection (collections::VecDeque). Inner collection length limited by number provided during structure construction. You are able to retrieve accumulated log records from inner collection using get_log_records method and clean inner collection using clear_log_records method.
OctalFormatter
This implementation of BufferFormatter trait formats provided bytes buffer in octal number system.
Record
This structure represents a log record and contains message string, creation timestamp (DateTime<Utc>) and record kind (RecordKind).
RecordKindFilter
This implementation of RecordFilter trait accepts allowed log record kinds (RecordKind) array during construction and its check method returns true if received log record kind presented inside this array.
UppercaseHexadecimalFormatter
This implementation of BufferFormatter trait formats provided bytes buffer in hexadecimal number system.

Enums§

RecordKind
This enumeration represents log record kind. It is contained inside Record and helps to determine how to work with log record message content which is different for each log record kind.

Traits§

BufferFormatter
This trait allows to format bytes buffer using format_buffer method. It should be implemented for structures which are going to be used as formatting part inside LoggedStream.
Logger
This trait allows to process log record (Record) using log method. It should be implemented for structures which are going to be used as logging part inside LoggedStream. Method log is called by LoggedStream for further log record processing (writing to the console, to the memory or database, etc.) after log record message was formatted by some implementation of BufferFormatter and the entire log record was filtered by some implementation of RecordFilter.
RecordFilter
This trait allows to filter log records (Record) using check method which returns bool value. It should be implemented for structures which are going to be used as filtering part inside LoggedStream.