From efb6a0975076581459028dd2dac57a468b10e445 Mon Sep 17 00:00:00 2001 From: Mark Allen Date: Thu, 16 Feb 2017 22:46:02 -0600 Subject: [PATCH] Add new filter expressions to README --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b7508a5..393274d 100644 --- a/README.md +++ b/README.md @@ -538,7 +538,8 @@ second argument if desired. You can also specify multiple expressions in a filter, or use the `*` atom as a wildcard to match any message that has that attribute, regardless of its -value. +value. You may also use the special value `!` to mean, only select if this +key is **not** present. Tracing to an existing logfile is also supported (but see **Multiple sink support** below): @@ -566,13 +567,17 @@ data-type that serializes well. To trace by pid, use the pid as a string: lager:trace_console([{pid, "<0.410.0>"}]) ``` -As of lager 2.0, you can also use a 3 tuple while tracing, where the second +### Filter expressions +As of lager 3.3.1, you can also use a 3 tuple while tracing where the second element is a comparison operator. The currently supported comparison operators are: * `<` - less than +* `=<` - less than or equal * `=` - equal to +* `!=` - not equal to * `>` - greater than +* `>=` - greater than or equal ```erlang lager:trace_console([{request, '>', 117}, {request, '<', 120}]) @@ -580,6 +585,25 @@ lager:trace_console([{request, '>', 117}, {request, '<', 120}]) Using `=` is equivalent to the 2-tuple form. +### Filter composition +As of lager 3.3.1 you may also use the special filter composition keys of +`all` or `any`. For example the filter example above could be +expressed as: + +```erlang +lager:trace_console([{all, [{request, '>', 117}, {request, '<', 120}]}]) +``` + +`any` has the effect of "OR style" logical evaluation between filters; `all` +means "AND style" logical evaluation between filters. These compositional filters +expect a list of additional filter expressions as their values. + +### Null filters +The `null` filter has a special meaning. A filter of `{null, false}` acts as +a black hole; nothing is passed through. A filter of `{null, true}` means +*everything* passes through. No other values for the null filter are valid and +will be rejected. + ### Multiple sink support If using multiple sinks, there are limitations on tracing that you