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 inKVFilterList
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]
fn new(
drain: D,
level: Level,
filters: HashMap<String, HashSet<String>>
) -> Self
drain: D,
level: Level,
filters: HashMap<String, HashSet<String>>
) -> Self
Create KVFilter
drain
- drain to be sent tolevel
- maximum level filtered, higher levels pass byfilters
- Hashmap of keys with lists of allowed values
Trait Implementations
impl<'a, D: Drain> Drain for KVFilter<D>
[src]
type Err = D::Err
Type of potential errors that can be returned by this Drain
type Ok = Option<D::Ok>
Type returned by this drain Read more
fn log(
&self,
info: &Record,
logger_values: &OwnedKVList
) -> Result<Self::Ok, Self::Err>
&self,
info: &Record,
logger_values: &OwnedKVList
) -> Result<Self::Ok, Self::Err>
Handle one logging statement (Record
) Read more
fn map<F, R>(self, f: F) -> R where
F: FnOnce(Self) -> R,
F: FnOnce(Self) -> R,
Pass Drain
through a closure, eg. to wrap into another Drain
. Read more
fn filter<F>(self, f: F) -> Filter<Self, F> where
F: FilterFn,
F: FilterFn,
Filter logging records passed to Drain
Read more
fn filter_level(self, level: Level) -> LevelFilter<Self>
Filter logging records passed to Drain
(by level) Read more
fn map_err<F, E>(self, f: F) -> MapError<Self, E> where
F: MapErrFn<Self::Err, E>,
F: MapErrFn<Self::Err, E>,
Map logging errors returned by this drain Read more
fn ignore_res(self) -> IgnoreResult<Self>
Ignore results returned by this drain Read more
fn fuse(self) -> Fuse<Self> where
Self::Err: Debug,
Self::Err: Debug,
Make Self
panic when returning any errors Read more