1logger_filters(3)          Erlang Module Definition          logger_filters(3)
2
3
4

NAME

6       logger_filters - Filters to use with Logger.
7

DESCRIPTION

9       All  functions exported from this module can be used as primary or han‐
10       dler  filters.  See  logger:add_primary_filter/2  and   logger:add_han‐
11       dler_filter/3 for more information about how filters are added.
12
13       Filters   are  removed  with  logger:remove_primary_filter/1  and  log‐
14       ger:remove_handler_filter/2.
15

EXPORTS

17       domain(LogEvent, Extra) -> logger:filter_return()
18
19              Types:
20
21                 LogEvent = logger:log_event()
22                 Extra = {Action, Compare, MatchDomain}
23                 Action = log | stop
24                 Compare = super | sub | equal | not_equal | undefined
25                 MatchDomain = [atom()]
26
27              This filter provides a way of filtering log events  based  on  a
28              domain  field  in Metadata. This field is optional, and the pur‐
29              pose of using it is to group log events  from,  for  example,  a
30              specific  functional  area.  This allows filtering or other spe‐
31              cialized treatment in a Logger handler.
32
33              A domain field must be a list of  atoms,  creating  smaller  and
34              more  specialized domains as the list grows longer. The greatest
35              domain is [], which comprises all possible domains.
36
37              For example, consider the following domains:
38
39              D1 = [otp]
40              D2 = [otp, sasl]
41
42              D1 is the greatest of the two, and is said to be a  super-domain
43              of  D2. D2 is a sub-domain D1. Both D1 and D2 are sub-domains of
44              [].
45
46              The above domains are used for logs originating from Erlang/OTP.
47              D1  specifies  that  the log event comes from Erlang/OTP in gen‐
48              eral, and D2 indicates that the log event is a  so  called  SASL
49              report.
50
51              The  Extra  parameter to the domain/2 function is specified when
52              adding  the  filter  via  logger:add_primary_filter/2  or   log‐
53              ger:add_handler_filter/3.
54
55              The  filter  compares  the  value of the domain field in the log
56              event's  metadata  (Domain)  against  MatchDomain.  The   filter
57              matches if the value of Compare is:
58
59                sub:
60                  and  Domain is equal to or a sub-domain of MatchDomain, that
61                  is, if MatchDomain is a prefix of Domain.
62
63                super:
64                  and Domain is equal to or  a  super-domain  of  MatchDomain,
65                  that is, if Domain is a prefix of MatchDomain.
66
67                equal:
68                  and Domain is equal to MatchDomain.
69
70                not_equal:
71                  and  Domain  differs  from  MatchDomain,  or  if there is no
72                  domain field in metadata.
73
74                undefined:
75                  and there is no domain  field  in  metadata.  In  this  case
76                  MatchDomain must be set to [].
77
78              If  the  filter  matches  and  Action  is  log, the log event is
79              allowed. If the filter matches and Action is stop, the log event
80              is stopped.
81
82              If  the  filter  does not match, it returns ignore, meaning that
83              other filters, or the value of the configuration parameter  fil‐
84              ter_default, decide if the event is allowed or not.
85
86              Log events that do not contain any domain field, match only when
87              Compare is equal to undefined or not_equal.
88
89              Example: stop all events with domain [otp, sasl | _]
90
91              logger:set_handler_config(h1, filter_default, log). % this is the default
92              Filter = {fun logger_filters:domain/2, {stop, sub, [otp, sasl]}}.
93              logger:add_handler_filter(h1, no_sasl, Filter).
94              ok
95
96       level(LogEvent, Extra) -> logger:filter_return()
97
98              Types:
99
100                 LogEvent = logger:log_event()
101                 Extra = {Action, Operator, MatchLevel}
102                 Action = log | stop
103                 Operator = neq | eq | lt | gt | lteq | gteq
104                 MatchLevel = logger:level()
105
106              This filter provides a way of filtering log events based on  the
107              log level. It matches log events by comparing the log level with
108              a specified MatchLevel
109
110              The Extra parameter is specified when adding the filter via log‐
111              ger:add_primary_filter/2 or logger:add_handler_filter/3.
112
113              The  filter  compares the value of the event's log level (Level)
114              to MatchLevel  by  calling  logger:compare_levels(Level,  Match‐
115              Level). The filter matches if the value of Operator is:
116
117                neq:
118                  and the compare function returns lt or gt.
119
120                eq:
121                  and the compare function returns eq.
122
123                lt:
124                  and the compare function returns lt.
125
126                gt:
127                  and the compare function returns gt.
128
129                lteq:
130                  and the compare function returns lt or eq.
131
132                gteq:
133                  and the compare function returns gt or eq.
134
135              If  the  filter  matches  and  Action  is  log, the log event is
136              allowed. If the filter matches and Action is stop, the log event
137              is stopped.
138
139              If  the  filter  does not match, it returns ignore, meaning that
140              other filters, or the value of the configuration parameter  fil‐
141              ter_default, will decide if the event is allowed or not.
142
143              Example: only allow debug level log events
144
145              logger:set_handler_config(h1, filter_default, stop).
146              Filter = {fun logger_filters:level/2, {log, eq, debug}}.
147              logger:add_handler_filter(h1, debug_only, Filter).
148              ok
149
150       progress(LogEvent, Extra) -> logger:filter_return()
151
152              Types:
153
154                 LogEvent = logger:log_event()
155                 Extra = log | stop
156
157              This  filter  matches  all  progress reports from supervisor and
158              application_controller.
159
160              If Extra is log, the progress reports are allowed. If  Extra  is
161              stop, the progress reports are stopped.
162
163              The filter returns ignore for all other log events.
164
165       remote_gl(LogEvent, Extra) -> logger:filter_return()
166
167              Types:
168
169                 LogEvent = logger:log_event()
170                 Extra = log | stop
171
172              This  filter  matches all events originating from a process that
173              has its group leader on a remote node.
174
175              If Extra is log, the matching events are allowed.  If  Extra  is
176              stop, the matching events are stopped.
177
178              The filter returns ignore for all other log events.
179

SEE ALSO

181       logger(3)
182
183
184
185Ericsson AB                       kernel 7.3                 logger_filters(3)
Impressum