Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Fix hierarchical logging documentation #171

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,30 @@ their `onRecord` streams.
});


// Will NOT print because FINER is too low level for `Logger.root`.
// Will NOT print because FINER is too low level for ([LOG1] & [ROOT]).
log1.finer('LOG_01 FINER (X)');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is correct, I've just updated the comment to be more clear.


// Will print twice ([LOG1] & [ROOT])
log1.fine('LOG_01 FINE (√)');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is incorrect.
It should print once by [LOG1] only as the root logger has higher level WARNING.
As per Level definiton, logging level should enable logging only for all levels above the level not below it.

However, the output shows that the root logger fires which is actually a bug https://github.com/dart-lang/logging/issues/145

// Will print ONCE by [LOG1] because FINE is too low level for [ROOT].
log1.fine('LOG_01 FINE (√)');

// Will print ONCE because `log1` only uses root listener.
log1.warning('LOG_01 WARNING (√)');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is incorrect.
It should print twice as WARNING is sufficient for both [LOG1] & [ROOT], and the output actually print it twice as:

[LOG1][FINE+] LOG_01 WARNING (√)
[ROOT][WARNING+] LOG_01 WARNING (√)

// Will print twice ([LOG1] & [ROOT]) because warning is sufficient for all
// loggers' levels.
log1.warning('LOG_01 WARNING (√√)');

// Will never print because FINE is too low level.
// Will NOT print because FINE is too low level for ([LOG1] & [ROOT]).
log2.fine('LOG_02 FINE (X)');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is correct, I've just updated the comment to be more clear.


// Will print twice ([LOG2] & [ROOT]) because warning is sufficient for all
// loggers' levels.
log2.warning('LOG_02 WARNING (√√)');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is correct.


// Will never print because `info` is filtered by `Logger.root.level` of
// `Level.WARNING`.
log2.info('INFO (X)');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is correct but it's not needed as it's the same case as log2.fine('LOG_02 FINE (X)');

```

Results in:

```
[LOG1][FINE+] LOG_01 FINE (√√)
[ROOT][WARNING+] LOG_01 FINE (√√)
[LOG1][FINE+] LOG_01 WARNING (√)
[ROOT][WARNING+] LOG_01 WARNING (√)
[LOG1][FINE+] LOG_01 FINE (√)
[LOG1][FINE+] LOG_01 WARNING (√√)
[ROOT][WARNING+] LOG_01 WARNING (√√)
[LOG2][WARNING+] LOG_02 WARNING (√√)
[ROOT][WARNING+] LOG_02 WARNING (√√)
```
Expand Down