Skip to main content

Crate logged_stream

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:

  • Underlying IO object, which must implement Write and Read traits or their asynchronous analogues from tokio library: AsyncRead and AsyncWrite.
  • Buffer formatting part, which must implement BufferFormatter trait provided by this library. This part of LoggedStream is responsible for the form you will see the input and output bytes. Currently this library provides the following implementations of BufferFormatter trait: UppercaseHexadecimalFormatter, LowercaseHexadecimalFormatter, DecimalFormatter, BinaryFormatter and OctalFormatter. Also BufferFormatter is public trait so you are free to construct your own implementation.
  • Filtering part, which must implement RecordFilter trait provided by this library. This part of LoggedStream is responsible for log records filtering. Currently this library provides the following implementations of RecordFilter trait: DefaultFilter which accepts all log records, RecordKindFilter which accepts logs with kinds specified during construct, AllFilter which combines multiple filters with AND logic (accepts record only if all underlying filters accept it), and AnyFilter which combines multiple filters with OR logic (accepts record if any underlying filter accepts it). Also RecordFilter is public trait and you are free to construct your own implementation.
  • Logging part, which must implement Logger trait provided by this library. This part of LoggedStream is responsible for further work with constructed, formatter and filtered log record. For example, it can be outputted to console, written to the file, written to database, written to the memory for further use or sended by the channel. Currently this library provides the following implementations of Logger trait: ConsoleLogger, MemoryStorageLogger, ChannelLogger and FileLogger. Also Logger is public trait and you are free to construct your own implementation.

Structs§

AllFilter
Implementation of RecordFilter that combines multiple filters with AND logic.
AnyFilter
Implementation of RecordFilter that combines multiple filters with OR logic.
BinaryFormatter
This implementation of BufferFormatter trait formats provided bytes buffer in binary number system.
ChannelLogger
Logger implementation that sends log records via an asynchronous channel.
ConsoleLogger
Logger implementation that writes log records to the console.
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
Wrapper for IO objects to log all read and write operations, errors, and drop events.
LowercaseHexadecimalFormatter
This implementation of BufferFormatter trait formats provided bytes buffer in hexadecimal number system.
MemoryStorageLogger
Logger implementation that writes log records to an inner VecDeque collection.
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
Implementation of RecordFilter that accepts allowed RecordKind 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
Trait for processing log records in LoggedStream.
RecordFilter
Trait for filtering log records in LoggedStream.