Commit 3b7ee61
Switch verbosity macros to use group argument (#73)
* Switch verbosity macros to use group argument
As noted in [this comment](https://github.com/JuliaLogging/LoggingExtras.jl/pull/64/files#r903295686),
there's currently a semantic error with the verbosity macros where even if my verbosity is
explicitly set to 0 or 1, but my log level is `Info`, then a message like:
```julia
@errorv 2 "more detailed error message than you normally want to see"
```
will still be logged, since the current logic just does `Error - 2`.
With the change proposed in this PR, we get the following change in behavior:
* If `LoggingExtras.withlevel` or an alternative filter doesn't inspect
the group.verbosity argument, then the verbose macros act just like
the normal logging macros
* If `withlevel` _is_ used, then the above case acts as expected; i.e.
the `@errorv 2 msg` case only logs if `withlevel(Info; verbosity=2)`
is set.
I opted to wrap the verbosity level in a new `LoggingExtras.Verbosity` struct
so that if the `group` argument is ever used for something else as an `Int`,
it won't accidentally conflict with the verbosity filtering. We'll still clobber
that argument if anyone else tries to use it, but it shouldn't affect cases where
people _aren't_ using the verbosity macros.
Fixes JuliaWeb/HTTP.jl#938.
* additional test
* Update src/verbosity.jl
Co-authored-by: Frames Catherine White <oxinabox@ucc.asn.au>
* inject Verbosity into quote expansion
Co-authored-by: Frames Catherine White <oxinabox@ucc.asn.au>1 parent be221f3 commit 3b7ee61
2 files changed
+31
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | | - | |
27 | | - | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
33 | | - | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
41 | | - | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
49 | | - | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
57 | | - | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
63 | 68 | | |
64 | 69 | | |
65 | | - | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| |||
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
78 | 87 | | |
79 | 88 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
| 259 | + | |
259 | 260 | | |
260 | 261 | | |
261 | 262 | | |
| |||
271 | 272 | | |
272 | 273 | | |
273 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
274 | 278 | | |
275 | 279 | | |
276 | 280 | | |
277 | | - | |
| 281 | + | |
| 282 | + | |
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
| |||
0 commit comments