Struct slog_kvfilter::KVFilter [] [src]

pub struct KVFilter<D: Drain> { /* fields omitted */ }

Drain filtering records using list of keys and values they must have unless they are of a higher level than filtering applied.

This Drain filters a log entry on a filtermap that holds the key name in question and acceptable values Key values are gathered up the whole hierarchy of inherited loggers.

Example

Logger( ... ; o!("thread" => "100"); log( ... ; "packet" => "send"); log( ... ; "packet" => "receive");

can be filtered on a map containing "thread" key component. If the values contain "100" the log will be output, otherwise filtered. The filtering map can contain further key "packet" and value "send". With that the output for "receive" would be filtered.

More precisely

  • a key is ignored until present in KVFilterList, otherwise an entry must match for all the keys present in KVFilterList for any of the value given for the key to pass the filter.
  • Behavior on empty KVFilterList is undefined but normally anything should pass.

Usage

Filtering in large systems that consist of multiple threads of same code or have functionality of interest spread across many components, modules, such as e.g. "sending packet" or "running FSM".

Methods

impl<'a, D: Drain> KVFilter<D>
[src]

Create KVFilter

  • drain - drain to be sent to
  • level - maximum level filtered, higher levels pass by
  • filters - Hashmap of keys with lists of allowed values

Trait Implementations

impl<'a, D: Drain> Drain for KVFilter<D>
[src]

Type of potential errors that can be returned by this Drain

Type returned by this drain Read more

Handle one logging statement (Record) Read more

Pass Drain through a closure, eg. to wrap into another Drain. Read more

Filter logging records passed to Drain Read more

Filter logging records passed to Drain (by level) Read more

Map logging errors returned by this drain Read more

Ignore results returned by this drain Read more

Make Self panic when returning any errors Read more