Repository navigation
Commit a40ca98
authored
Say what turning on hierarchical logging changes (#1293)
Follow-up to #1288. No behavior change, docs and one test.
## What was wrong in the docs
#1288 made `setLoggingLevel` and `disableLogging` work by turning on
`hierarchicalLoggingEnabled`. The doc comment said that with the switch
on "nothing else changes". That is not quite true:
- The switch applies to the whole isolate, so it also changes how an
app's own loggers deliver records. `onRecord` on a logger other than the
root one, listened to after the switch is on, delivers only the records
of that logger and its children. Before, it delivered everything.
- The README showed one snippet with `setLoggingLevel` and
`disableLogging` back to back, which reads as if both are needed.
## What this changes
- `lib/src/logger.dart`: the doc comments list what the switch changes.
A logger without a level follows its parent. Records still reach
`Logger.root.onRecord`. A non-root `onRecord` narrows to that logger and
its children.
- `README.md`: the Logging section has one snippet per call and says to
listen on `Logger.root.onRecord` to keep receiving everything.
- `test/logger_test.dart`: one more test, the SDK keeps its level when
the root level changes after `setLoggingLevel`.
## Checked against
`package:logging` 1.3.0 (`Logger.level`, `Logger.log`,
`Logger._getStream`), plus a throwaway probe with loggers `a`, `a.b` and
`c`. A listener on `a` added after the switch received `a` and `a.b`.
One added before the switch kept receiving all three. The root listener
received all three.
No change file. The entry for #1288 already covers this and is in the
2.14.0 changelog.1 parent 55ef223 commit a40ca98
3 files changed
Lines changed: 33 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
624 | | - | |
| 624 | + | |
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
628 | | - | |
629 | 628 | | |
630 | 629 | | |
631 | | - | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
632 | 639 | | |
633 | 640 | | |
634 | 641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
| 42 | + | |
| 43 | + | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| |||
0 commit comments