File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 138
138
[ Info: Yo Dawg! it is all good
139
139
```
140
140
141
+ ### Respecting `maxlog` convention
142
+
143
+ An `ActiveFilterLogger` can be used to wrap another logger to obey `maxlog` directives, for example,
144
+ similar to the `make_throttled_logger` example below,
145
+ ``` julia
146
+ function make_maxlog_logger (logger)
147
+ counts = Dict {Any,Int} ()
148
+ return ActiveFilteredLogger (logger) do log
149
+ maxlog = get (log. kwargs, :maxlog , nothing )
150
+ maxlog === nothing && return true # no limit
151
+ c = get (counts, log. id, 0 )
152
+ if c < maxlog
153
+ # log this message and update the count
154
+ counts[log. id] = c + 1
155
+ return true
156
+ else
157
+ return false
158
+ end
159
+ end
160
+ end
161
+ ```
162
+ wraps another logger to filter logs that have already fired `maxlog` many times.
163
+ See <https://docs.julialang.org/en/v1/stdlib/Logging/#Logging.@logmsg> for more on `maxlog`.
164
+
141
165
## `EarlyFilteredLogger` (*Filter*)
142
166
143
167
The `EarlyFilteredLogger` is similar to the `ActiveFilteredLogger`,
You can’t perform that action at this time.
0 commit comments