-
Notifications
You must be signed in to change notification settings - Fork 28
Merge package:logging
#401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
169 commits
Select commit
Hold shift + click to select a range
478291f
Move tests for things in /pkg into the right places for packages
alan-knight aac4197
Rename "tests" directories under /pkg to the singular "test"
alan-knight 8a3028b
Require two type arguments for map literals (issue 4522).
crelier e839b3a
- Change "static final" to "static const" in the
iposva-google ffa85cc
Get rid of a lot of () for getters.
5c3d31a
Move logging to the new package layout.
munificent 2825458
Make unittest follow the new package layout.
munificent 1fa01de
Revert "Make unittest follow the new package layout."
munificent 9800b66
Update unittest to new package layout.
munificent 3e9e185
revert 1204. Will investigate when I get a chance.
efortuna b7c30f8
Change IllegalArgumentException to ArgumentError.
lrhn 45957ca
Stop using the Hashable interface.
lrhn ae5ef40
fix warning in Logger
cacbf8f
Make hashCode a getter and not a method.
floitschG d302150
Parts must start with 'part of'
scheglov 16b42cd
Revert "Parts must start with 'part of'" and "Attempt to fix VM build"
peter-ahe-google 36f6837
Removed IllegalAccessException and UnsupportedOperationException.
lrhn dc434d9
Modified unittest to use new argument syntax.
c044d28
Restructure pkg/unittest and pkg/webdriver to follow the pub conventi…
18f259e
Update library syntax in pkg files.
f0633a9
a === b -> identical(a, b)
floitschG 5d0f3d2
Add authors and homepages to packages.
dgrove 78a4ee1
Convert the small packages in pkg to use "package:".
munificent 32cf3de
Fix URL.
munificent 5708cd2
Rename Date to DateTime.
floitschG 2e0ef35
Added documentation links to all of the pkg packages hosted on api.da…
amouravski 0f7b273
Update documentation links to point to the correct URLs.
dgrove d57e1f4
Make Comparable generic.
lrhn cea2ad3
Revert "Make Comparable generic."
3b9b898
Reapply "Make Comparable generic."
lrhn f0c3cd5
make dartdoc and editor happy
sigmundch 82a34df
LoggerEvents get on -> Stream<LogRecord> get onRecord
sigmundch 62985e0
Don't use package: imports in logging until dartdoc/mirros support them.
sigmundch fbfbc94
Moved pkg pubspecs to use dev_dependencies where appropriate
kevmoo f80f4b9
Make path to meta go through pkg/ , so that it's rewritten properly.
dgrove 27d5ad8
pkg/logging: removed deprecated 'on' API
kevmoo f52ed0a
Switch pkg packages, pub, and dartdoc to use package: imports.
nex3 d06a26d
Remove StreamController.broadcast.
floitschG 9fafd48
add installation instructions to pkg packages
sethladd 685c91b
Make new StreamController be async by default.
lrhn 4ed8407
add logging support for exceptions
sigmundch de38a7e
Make asBroadcastStream take two callbacks.
lrhn 7c55991
Update meta and logging library descriptions; tweak fixnum
kwalrath 64517e7
Add a toString() to LogRecord.
devoncarew 7653e23
pkg/logging: added stackTrace support
kevmoo 3f74838
Remove @deprecated features.
lrhn 8e00240
Revert "Remove @deprecated features."
lrhn 5c06cae
Add @proxy to annotations.dart.
lrhn 4ec85e0
Reapply "Remove @deprecated features."
lrhn 28a03cb
add useful docs for logging
sethladd dd83bc1
add versions and constraints for packages and samples
3b03578
Revert "add versions and constraints for packages and samples"
61739cb
Re-land r29957 (add versions and constraints for packages and samples…
dgrove 7599a0b
Combine unmodifiable_collection package into collection_helpers.
lrhn 8bbc732
pkg/logging: expose static sorted const list of all levels
kevmoo 1ddb964
update pubspecs for pkg uploading
ecdaebe
add LICENSE AUTHORS PATENTS so we can publish
865af31
Create associated packages for the dart:collection and dart:async libs.
lrhn ba55eb6
flagging pkg/args and pkg/logging as dev+1
kevmoo 26480d6
pkg/logging: use UnmodifiableMapView from dart:collection
kevmoo 05bdd75
updated logging package to accept functions or other non-string objec…
jakemac53 b367687
Update the pubspec's homepage link.
nex3 f19d447
Make type signature consistent with class Object
jacob314 c0b3497
Adding a "zone" value to "class LogRecord"
mkustermann e6e65f6
Allow a greater range of types as a stack trace
Fox32 c66456d
Merge pull request dart-lang/logging#1 from Fox32/feature/stacktrace_…
77cc905
Revert change to make stackTrace object
kevmoo c6a6118
dartfmt
kevmoo 36292c7
tweaked readme example
kevmoo 972f7cc
move to test pkg
kevmoo d8ac950
ship 0.11.0
kevmoo f060bc8
Add option to automatically record stack trace in logging (fixes dart…
sigmundch 083d3d2
Improve Logger.root (static final instead of getter that looks the ca…
ochafik d503357
Merge pull request dart-lang/logging#24 from ochafik/patch-1
sigmundch 85d8c60
Also generate error when autogenerating stack traces (fix dart-lang/l…
sigmundch a7686ff
Add Logger.detached factory
astashov a6d5cfd
Merge pull request dart-lang/logging#27 from astashov/add-orphan-factory
sigmundch 1c327a6
Add changelog entry
sigmundch b7807a9
save non-string object on LogRecord (dart-lang/logging#28)
jasonaguilon-wf 22967da
dartfmt
kevmoo 668275c
cleanup .gitignore
kevmoo beb4476
Fixing some doc comments
srawlins 0d41cdc
Use correct config for pkg/test on bots
kevmoo a617f85
Enable travis, add analysis_options, other cleanup (dart-lang/logging…
kevmoo cb48b22
Allow chrome tests to fail (dart-lang/logging#37)
kevmoo af83904
Remove dartium from travis tests (dart-lang/logging#38)
kevmoo 974c007
Delete PATENTS
kevmoo dc9d3f9
chore: set max SDK version to <3.0.0 (dart-lang/logging#40)
chalin 5351247
Update to best practices in README
natebosch 79cf597
Merge pull request dart-lang/logging#42 from dart-lang/readme-style
natebosch a8c0425
Update README.md
pq 776e8ad
Update README.md
pq 4937e03
Merge pull request dart-lang/logging#47 from dart-lang/travis-badge
pq 898d4fa
Update README.md
pq 34c0f56
Merge pull request dart-lang/logging#48 from dart-lang/pub-shield
pq 343a55e
dartfmt --fix, update min SDK to 2.0.0
kevmoo b8e1b54
Enable a number of new lints
kevmoo a7288c3
Only test one browser
kevmoo f5caf23
minor cleanups (dart-lang/logging#50)
pq d1ec82a
Document default LogLevel (dart-lang/logging#58)
jonasfj a4cfb98
Test travis on oldest supported SDK (dart-lang/logging#59)
kevmoo 194b953
Fix dartlang.org links and add a missing dartfmt lint (dart-lang/logg…
kevmoo 03783e3
Refactor into mini-libraries (dart-lang/logging#64)
kevmoo 0db7a07
Replace _rootLevel with root._level (dart-lang/logging#69)
jamesderlin 14084f1
Add changelog entry for defaultLevel (dart-lang/logging#70)
natebosch fbe62b4
Make detached Loggers work regardless of hierarchicalLoggingEnabled (…
jamesderlin 980b9ee
prepare to release 0.11.4 (dart-lang/logging#72)
jakemac53 a8750ab
Reference docs for message arguments (dart-lang/logging#77)
natebosch 013f6c0
Delete .test_config
kevmoo 8350442
Migrate to null safety (dart-lang/logging#82)
jakemac53 a7656b1
update sdk constraint to allow 2.11 dev (dart-lang/logging#84)
jakemac53 66eee20
Support Dart 2.11 (dart-lang/logging#85)
kevmoo f4f0b4c
final cleanup, prep null safety release (dart-lang/logging#86)
jakemac53 73005cc
typos (dart-lang/logging#87)
pq 979df4f
remove redundant experiment (dart-lang/logging#88)
pq e1a5df4
remove publish_to: none (dart-lang/logging#90)
jakemac53 95e33aa
Migrate to GitHub Actions (dart-lang/logging#94)
athomas 1d474a4
stable null safety release (dart-lang/logging#95)
jakemac53 37bdd56
List the log levels in the README (dart-lang/logging#97)
natebosch a7226fa
Update LICENSE (dart-lang/logging#98)
franklinyow e7ee3bc
Move from pedantic to lints package (dart-lang/logging#102)
natebosch ed5ce02
Add example, update description (dart-lang/logging#103)
mit-mit a0c2ff4
Enable the avoid_dynamic_calls lint (dart-lang/logging#112)
devoncarew d2d1f17
Add Logger.attachedLoggers to return the known Logger objects (dart-l…
powerb33 f10819b
Drop invariant_booleans from lints (dart-lang/logging#117)
kevmoo f5c9702
add file copyrights and misc changes (dart-lang/logging#119)
devoncarew 361204d
update CI config (dart-lang/logging#121)
devoncarew 46490c6
Create no-response.yml (dart-lang/logging#124)
devoncarew 8c634ac
Add a check that throws if a logger name ends with '.' (dart-lang/log…
predatorx7 dac77f8
Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/logging#125)
dependabot[bot] 58e6fe4
Move to new analyzer language settings (dart-lang/logging#126)
kevmoo 1465611
add a publish script; prep to publish 1.1.1 (dart-lang/logging#128)
devoncarew 5f86536
Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/logging#129)
dependabot[bot] 9d5989a
Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/logging#130)
dependabot[bot] ddaeb56
Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/logging#134)
dependabot[bot] 6d92fd8
Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/logging#133)
dependabot[bot] 682f769
Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/logging#136)
dependabot[bot] 0e7b4df
blast_repo fixes (dart-lang/logging#137)
devoncarew 0f5e913
Logger `onLevelChanged` notification (dart-lang/logging#138)
desistefanova 627428e
blast_repo fixes (dart-lang/logging#141)
devoncarew 9b17272
blast_repo fixes (dart-lang/logging#142)
devoncarew 0bb76e5
prep for release (dart-lang/logging#140)
jakemac53 4d6045e
Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/logging#144)
dependabot[bot] edaceeb
Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/logging#147)
dependabot[bot] da0bdae
Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/logging#148)
dependabot[bot] cc91899
Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/logging#149)
dependabot[bot] cccfda5
Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/logging#151)
dependabot[bot] f2c4229
Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/logging#150)
dependabot[bot] 098675a
Bump actions/stale from 8.0.0 to 9.0.0 (dart-lang/logging#152)
dependabot[bot] bef87f3
blast_repo fixes (dart-lang/logging#154)
kevmoo b539ee9
Hierarchical logging documentation (dart-lang/logging#146)
craiglabenz 2de688a
update min SDK and deps (dart-lang/logging#155)
kevmoo 3f7c113
Bump dart-lang/setup-dart from 1.6.1 to 1.6.2 (dart-lang/logging#157)
dependabot[bot] 3ae5f9a
Override empty stack traces for traced events (dart-lang/logging#158)
natebosch 0ddcee3
Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/logging#160)
dependabot[bot] 0e3dbb6
Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/logging#162)
dependabot[bot] 8397ba0
Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/logging#161)
dependabot[bot] c4b8ecf
Add `topics` to `pubspec.yaml` (dart-lang/logging#164)
jonasfj eacc928
Bump actions/checkout from 4.1.4 to 4.1.6 (dart-lang/logging#166)
dependabot[bot] ddda561
Update `topics` in `pubspec.yaml` (dart-lang/logging#165)
szakarias 8b5427b
Update lints dep, bump min SDK (dart-lang/logging#167)
kevmoo 456e9e7
Bump actions/checkout from 4.1.6 to 4.1.7 (dart-lang/logging#168)
dependabot[bot] bba9edb
blast_repo fixes (dart-lang/logging#170)
kevmoo 168f541
Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group…
dependabot[bot] 77c93eb
Fix typo in README (dart-lang/logging#173)
lawther 32a7c39
Merge package:logging into the core monorepo
mosuem bafb17e
Add issue template and other fixes
mosuem b3d67ea
Moving fixes
mosuem 31caf59
Add license to example file
mosuem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
name: "package:logging" | ||
about: "Create a bug or file a feature request against package:logging." | ||
labels: "package:logging" | ||
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: package:logging | ||
|
||
on: | ||
# Run CI on pushes to the main branch, and on PRs against main. | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/logging.yaml' | ||
- 'pkgs/logging/**' | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/logging.yaml' | ||
- 'pkgs/logging/**' | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
env: | ||
PUB_ENVIRONMENT: bot.github | ||
|
||
defaults: | ||
run: | ||
working-directory: pkgs/logging/ | ||
|
||
jobs: | ||
# Check code formatting and static analysis. | ||
analyze: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
sdk: [dev] | ||
steps: | ||
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 | ||
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 | ||
with: | ||
sdk: ${{ matrix.sdk }} | ||
- id: install | ||
name: Install dependencies | ||
run: dart pub get | ||
- name: Check formatting | ||
run: dart format --output=none --set-exit-if-changed . | ||
if: always() && steps.install.outcome == 'success' | ||
- name: Analyze code | ||
run: dart analyze --fatal-infos | ||
if: always() && steps.install.outcome == 'success' | ||
|
||
# Run tests on a matrix of platforms and sdk versions. | ||
test: | ||
needs: analyze | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# Add macos-latest and/or windows-latest if relevant for this package. | ||
os: [ubuntu-latest] | ||
sdk: [3.4, dev] | ||
steps: | ||
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 | ||
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 | ||
with: | ||
sdk: ${{ matrix.sdk }} | ||
- id: install | ||
name: Install dependencies | ||
run: dart pub get | ||
- name: Run VM tests | ||
run: dart test --platform vm | ||
if: always() && steps.install.outcome == 'success' | ||
- name: Run Chrome tests | ||
run: dart test --platform chrome | ||
if: always() && steps.install.outcome == 'success' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.dart_tool | ||
.packages | ||
pubspec.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Names should be added to this file with this pattern: | ||
# | ||
# For individuals: | ||
# Name <email address> | ||
# | ||
# For organizations: | ||
# Organization <fnmatch pattern> | ||
# | ||
Google Inc. <*@google.com> | ||
Anton Astashov <[email protected]> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
## 1.3.0 | ||
|
||
* Override empty stack traces for trace level events. | ||
* Require Dart 3.4 | ||
* Move to `dart-lang/core` monorepo. | ||
|
||
## 1.2.0 | ||
|
||
* Add notification when the log level is changed. Logger `onLevelChanged` broadcasts a stream of level values. | ||
* Require Dart 2.19. | ||
|
||
## 1.1.1 | ||
|
||
* Add a check that throws if a logger name ends with '.'. | ||
* Require Dart 2.18 | ||
|
||
## 1.1.0 | ||
|
||
* Add `Logger.attachedLoggers` which exposes all loggers created with the | ||
default constructor. | ||
* Enable the `avoid_dynamic_calls` lint. | ||
|
||
## 1.0.2 | ||
|
||
* Update description. | ||
* Add example. | ||
|
||
## 1.0.1 | ||
|
||
* List log levels in README. | ||
|
||
## 1.0.0 | ||
|
||
* Stable null safety release. | ||
|
||
## 1.0.0-nullsafety.0 | ||
|
||
* Migrate to null safety. | ||
* Removed the deprecated `LoggerHandler` typedef. | ||
|
||
## 0.11.4 | ||
|
||
* Add top level `defaultLevel`. | ||
* Require Dart `>=2.0.0`. | ||
* Make detached loggers work regardless of `hierarchicalLoggingEnabled`. | ||
|
||
## 0.11.3+2 | ||
|
||
* Set max SDK version to `<3.0.0`, and adjust other dependencies. | ||
|
||
## 0.11.3+1 | ||
|
||
* Fixed several documentation comments. | ||
|
||
## 0.11.3 | ||
|
||
* Added optional `LogRecord.object` field. | ||
|
||
* `Logger.log` sets `LogRecord.object` if the message is not a string or a | ||
function that returns a string. So that a handler can access the original | ||
object instead of just its `toString()`. | ||
|
||
## 0.11.2 | ||
|
||
* Added `Logger.detached` - a convenience factory to obtain a logger that is not | ||
attached to this library's logger hierarchy. | ||
|
||
## 0.11.1+1 | ||
|
||
* Include default error with the auto-generated stack traces. | ||
|
||
## 0.11.1 | ||
|
||
* Add support for automatically logging the stack trace on error messages. Note | ||
this can be expensive, so it is off by default. | ||
|
||
## 0.11.0 | ||
|
||
* Revert change in `0.10.0`. `stackTrace` must be an instance of `StackTrace`. | ||
Use the `Trace` class from the [stack_trace package][] to convert strings. | ||
|
||
[stack_trace package]: https://pub.dev/packages/stack_trace | ||
|
||
## 0.10.0 | ||
|
||
* Change type of `stackTrace` from `StackTrace` to `Object`. | ||
|
||
## 0.9.3 | ||
|
||
* Added optional `LogRecord.zone` field. | ||
|
||
* Record current zone (or user specified zone) when creating new `LogRecord`s. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright 2013, the Dart project authors. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google LLC nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
[](https://github.com/dart-lang/core/actions/workflows/logging.yaml) | ||
[](https://pub.dev/packages/logging) | ||
[](https://pub.dev/packages/logging/publisher) | ||
|
||
## Initializing | ||
|
||
By default, the logging package does not do anything useful with the log | ||
messages. You must configure the logging level and add a handler for the log | ||
messages. | ||
|
||
Here is a simple logging configuration that logs all messages via `print`. | ||
|
||
```dart | ||
Logger.root.level = Level.ALL; // defaults to Level.INFO | ||
Logger.root.onRecord.listen((record) { | ||
print('${record.level.name}: ${record.time}: ${record.message}'); | ||
}); | ||
``` | ||
|
||
First, set the root `Level`. All messages at or above the current level are sent to the | ||
`onRecord` stream. Available levels are: | ||
|
||
+ `Level.OFF` | ||
+ `Level.SHOUT` | ||
+ `Level.SEVERE` | ||
+ `Level.WARNING` | ||
+ `Level.INFO` | ||
+ `Level.CONFIG` | ||
+ `Level.FINE` | ||
+ `Level.FINER` | ||
+ `Level.FINEST` | ||
|
||
Then, listen on the `onRecord` stream for `LogRecord` events. The `LogRecord` | ||
class has various properties for the message, error, logger name, and more. | ||
|
||
To listen for changed level notifications use: | ||
|
||
```dart | ||
Logger.root.onLevelChanged.listen((level) { | ||
print('The new log level is $level'); | ||
}); | ||
``` | ||
|
||
## Logging messages | ||
|
||
Create a `Logger` with a unique name to easily identify the source of the log | ||
messages. | ||
|
||
```dart | ||
final log = Logger('MyClassName'); | ||
``` | ||
|
||
Here is an example of logging a debug message and an error: | ||
|
||
```dart | ||
var future = doSomethingAsync().then((result) { | ||
log.fine('Got the result: $result'); | ||
processResult(result); | ||
}).catchError((e, stackTrace) => log.severe('Oh noes!', e, stackTrace)); | ||
``` | ||
|
||
When logging more complex messages, you can pass a closure instead that will be | ||
evaluated only if the message is actually logged: | ||
|
||
```dart | ||
log.fine(() => [1, 2, 3, 4, 5].map((e) => e * 4).join("-")); | ||
``` | ||
|
||
Available logging methods are: | ||
|
||
+ `log.shout(logged_content);` | ||
+ `log.severe(logged_content);` | ||
+ `log.warning(logged_content);` | ||
+ `log.info(logged_content);` | ||
+ `log.config(logged_content);` | ||
+ `log.fine(logged_content);` | ||
+ `log.finer(logged_content);` | ||
+ `log.finest(logged_content);` | ||
|
||
## Configuration | ||
|
||
Loggers can be individually configured and listened to. When an individual logger has no | ||
specific configuration, it uses the configuration and any listeners found at `Logger.root`. | ||
|
||
To begin, set the global boolean `hierarchicalLoggingEnabled` to `true`. | ||
|
||
Then, create unique loggers and configure their `level` attributes and assign any listeners to | ||
their `onRecord` streams. | ||
|
||
|
||
```dart | ||
hierarchicalLoggingEnabled = true; | ||
Logger.root.level = Level.WARNING; | ||
Logger.root.onRecord.listen((record) { | ||
print('[ROOT][WARNING+] ${record.message}'); | ||
}); | ||
|
||
final log1 = Logger('FINE+'); | ||
log1.level = Level.FINE; | ||
log1.onRecord.listen((record) { | ||
print('[LOG1][FINE+] ${record.message}'); | ||
}); | ||
|
||
// log2 inherits LEVEL value of WARNING from `Logger.root` | ||
final log2 = Logger('WARNING+'); | ||
log2.onRecord.listen((record) { | ||
print('[LOG2][WARNING+] ${record.message}'); | ||
}); | ||
|
||
|
||
// Will NOT print because FINER is too low level for `Logger.root`. | ||
log1.finer('LOG_01 FINER (X)'); | ||
|
||
// Will print twice ([LOG1] & [ROOT]) | ||
log1.fine('LOG_01 FINE (√√)'); | ||
|
||
// Will print ONCE because `log1` only uses root listener. | ||
log1.warning('LOG_01 WARNING (√)'); | ||
|
||
// Will never print because FINE is too low level. | ||
log2.fine('LOG_02 FINE (X)'); | ||
|
||
// Will print twice ([LOG2] & [ROOT]) because warning is sufficient for all | ||
// loggers' levels. | ||
log2.warning('LOG_02 WARNING (√√)'); | ||
|
||
// Will never print because `info` is filtered by `Logger.root.level` of | ||
// `Level.WARNING`. | ||
log2.info('INFO (X)'); | ||
``` | ||
|
||
Results in: | ||
|
||
``` | ||
[LOG1][FINE+] LOG_01 FINE (√√) | ||
[ROOT][WARNING+] LOG_01 FINE (√√) | ||
[LOG1][FINE+] LOG_01 WARNING (√) | ||
[ROOT][WARNING+] LOG_01 WARNING (√) | ||
[LOG2][WARNING+] LOG_02 WARNING (√√) | ||
[ROOT][WARNING+] LOG_02 WARNING (√√) | ||
``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.