You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tracing-filter is 99.999% compatible with [env_logger](lib.rs/env_logger)'s
@@ -15,32 +32,63 @@ filter syntax. As such, you can write simple filters the way you always have:
15
32
-`my_app=debug` — filter to `DEBUG` or higher events only from `my_app`
16
33
-`warn,my_app::module=trace` — get warning events and trace `my_app::module`
17
34
-`off` — disable all logging
18
-
-`trace/foo` — get all events whose message contains "`foo`"
35
+
-`debug/foo` — filter to `DEBUG` or higher events whose message contains "`foo`"
19
36
20
37
In general, the syntax is `target=level/regex`. An event is included if its
21
38
target *starts with* the listed `target`, its level passes the `level` filter,
22
-
and its message matches `regex`. The only non-compatible behavior is that to use
23
-
a simple filter, the filter must not start with the character `(`. This only
24
-
impacts log events that specify a custom `target`. Additionally, `/filter` can
25
-
only be used with the `regex` feature; it's ignored otherwise. With the
26
-
env_logger crate, it would be interpreted as a simple substring filter.
39
+
and its message matches `regex`. With the env_logger crate, the regex string
40
+
is a simple substring match if you don't enable the `regex` feature; with our
41
+
simple filters,
42
+
43
+
**This should be 99%<sup>†</sup> functional in the `tracing_filter::simple` module.**
44
+
45
+
<sup>†</sup>: tracing does not allow filtering on events' fields' contents
46
+
[yet](https://github.com/tokio-rs/tracing/pull/2008). tracing-filter chooses to
47
+
just siliently ignore the regex filter for the time being (but it does validate
48
+
the filter).
49
+
50
+
### Legacy filters
51
+
52
+
The filter syntax supported by [email protected]'s `EnvFilter`, complete
53
+
with all of its p̛̭a͖͕ŕ̯̪̥͈̠̙̣s͙̪̮̟͠i̥̞̠n͍̙̭͡g̸̜̤̦̤̳͍ ͓͜ẉ̨̳̠̗̗i̱t͚̹͉̯h̢̩̤̹͙̩͙ ̪̻͈r̻̙̥̭̯̫e̮̭̞̣̮͕̪g҉̦͚̬̖e͇̕x̛͖̣̮̞̜ͅ "peculiarites"; 100% bug-for-bug compatible.
27
54
28
-
If the filter is a simple filter, it must entirely be a simple filter.
29
-
You may not mix simple filters with query filters.
55
+
As such, you can use all of the filters that you have been using:
56
+
57
+
-`warn` — filter to only events of level `WARN` or `ERROR`
58
+
-`my_app=debug` — filter to `DEBUG` or higher events only from `my_app`
59
+
-`warn,my_app::module=trace` — get warning events and trace `my_app::module`
60
+
-`off` — disable all logging
61
+
-`[span]=debug` — filter to `DEBUG` or higher events inside a span named `span`
62
+
-`[{field}]` — filter to events with a field `field` or within a span with name `field`
63
+
-`[{key=val}]` — filter to events within a span with field `key` that matches the regex `val`
64
+
-`[{key=0}]` — filter to events within a span with field `key` that recorded a number that equals `0`
65
+
-`[{key=true}]` — filter to events within a span with field `key` that recorded a boolean value of `true`
66
+
-`target[span]` — filter to events within a span with target `target` and name `span`
67
+
68
+
In general, the syntax is `target[span{field=value}]=level`.
69
+
70
+
**This should be 100% functional in the `tracing_filter::legacy` module.**
30
71
31
72
### Query filters
32
73
33
74
Query filters are tracing-filter's way of selecting events and taking advantage
34
-
of tracing's structured events.
75
+
of tracing's structured events. Query filters are a 99% superset of simple
76
+
filters; specifically, for each `,` separated directive, it's treated as a query
77
+
filter if and only if it starts with `(`; otherwise it is treated as a simple
0 commit comments