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
WriteandReadtraits or their asynchronous analogues fromtokiolibrary:AsyncReadandAsyncWrite. - Buffer formatting part, which must implement
BufferFormattertrait provided by this library. This part ofLoggedStreamis responsible for the form you will see the input and output bytes. Currently this library provides the following implementations ofBufferFormattertrait:UppercaseHexadecimalFormatter,LowercaseHexadecimalFormatter,DecimalFormatter,BinaryFormatterandOctalFormatter. AlsoBufferFormatteris public trait so you are free to construct your own implementation. - Filtering part, which must implement
RecordFiltertrait provide by this library. This part ofLoggedStreamis responsible for log records filtering. Currently this library provides the following implementation ofRecordFiltertrait:DefaultFilterwhich accepts all log records andRecordKindFilterwhich accepts logs with kinds specified during construct. AlsoRecordFilteris public trait and you are free to construct your own implementation. - Logging part, which must implement
Loggertrait provided by this library. This part ofLoggedStreamis 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 ofLoggertrait:ConsoleLogger,MemoryStorageLogger,ChannelLoggerandFileLogger. AlsoLoggeris public trait and you are free to construct your own implementation.
Structs§
- Binary
Formatter - This implementation of
BufferFormattertrait formats provided bytes buffer in binary number system. - Channel
Logger - Logger implementation that sends log records via an asynchronous channel.
- Console
Logger - Logger implementation that writes log records to the console.
- Decimal
Formatter - This implementation of
BufferFormattertrait formats provided bytes buffer in decimal number system. - Default
Filter - This is default implementation of
RecordFiltertrait whichcheckmethod always returntrue. It should be constructed usingDefault::defaultmethod. - File
Logger - This implementation of
Loggertrait writes log records (Record) into provided file. - Logged
Stream - Wrapper for IO objects to log all read and write operations, errors, and drop events.
- Lowercase
Hexadecimal Formatter - This implementation of
BufferFormattertrait formats provided bytes buffer in hexdecimal number system. - Memory
Storage Logger - Logger implementation that writes log records to an inner
VecDequecollection. - Octal
Formatter - This implementation of
BufferFormattertrait 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). - Record
Kind Filter - Implementation of
RecordFilterthat accepts allowedRecordKindarray. - Uppercase
Hexadecimal Formatter - This implementation of
BufferFormattertrait formats provided bytes buffer in hexadecimal number system.
Enums§
- Record
Kind - This enumeration represents log record kind. It is contained inside
Recordand helps to determine how to work with log record message content which is different for each log record kind.
Traits§
- Buffer
Formatter - This trait allows to format bytes buffer using
format_buffermethod. It should be implemented for structures which are going to be used as formatting part insideLoggedStream. - Logger
- Trait for processing log records in
LoggedStream. - Record
Filter - Trait for filtering log records in
LoggedStream.