Skip to content
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

Merge package:logging #401

Merged
merged 169 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
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 Aug 14, 2012
aac4197
Rename "tests" directories under /pkg to the singular "test"
alan-knight Aug 15, 2012
8a3028b
Require two type arguments for map literals (issue 4522).
crelier Aug 16, 2012
e839b3a
- Change "static final" to "static const" in the
iposva-google Aug 31, 2012
ffa85cc
Get rid of a lot of () for getters.
Sep 7, 2012
5c3d31a
Move logging to the new package layout.
munificent Sep 13, 2012
2825458
Make unittest follow the new package layout.
munificent Sep 14, 2012
1fa01de
Revert "Make unittest follow the new package layout."
munificent Sep 14, 2012
9800b66
Update unittest to new package layout.
munificent Sep 14, 2012
3e9e185
revert 1204. Will investigate when I get a chance.
efortuna Sep 15, 2012
b7c30f8
Change IllegalArgumentException to ArgumentError.
lrhn Sep 25, 2012
45957ca
Stop using the Hashable interface.
lrhn Sep 27, 2012
ae5ef40
fix warning in Logger
Oct 19, 2012
cacbf8f
Make hashCode a getter and not a method.
floitschG Oct 22, 2012
d302150
Parts must start with 'part of'
scheglov Oct 23, 2012
16b42cd
Revert "Parts must start with 'part of'" and "Attempt to fix VM build"
peter-ahe-google Oct 23, 2012
36f6837
Removed IllegalAccessException and UnsupportedOperationException.
lrhn Oct 24, 2012
dc434d9
Modified unittest to use new argument syntax.
gramster Oct 26, 2012
c044d28
Restructure pkg/unittest and pkg/webdriver to follow the pub conventi…
gramster Nov 1, 2012
18f259e
Update library syntax in pkg files.
gramster Nov 7, 2012
f0633a9
a === b -> identical(a, b)
floitschG Nov 12, 2012
5d0f3d2
Add authors and homepages to packages.
dgrove Nov 30, 2012
78a4ee1
Convert the small packages in pkg to use "package:".
munificent Dec 15, 2012
32cf3de
Fix URL.
munificent Dec 15, 2012
5708cd2
Rename Date to DateTime.
floitschG Jan 24, 2013
2e0ef35
Added documentation links to all of the pkg packages hosted on api.da…
amouravski Feb 12, 2013
0f7b273
Update documentation links to point to the correct URLs.
dgrove Feb 15, 2013
d57e1f4
Make Comparable generic.
lrhn Feb 19, 2013
cea2ad3
Revert "Make Comparable generic."
Feb 19, 2013
3b9b898
Reapply "Make Comparable generic."
lrhn Feb 19, 2013
f0c3cd5
make dartdoc and editor happy
sigmundch Feb 27, 2013
82a34df
LoggerEvents get on -> Stream<LogRecord> get onRecord
sigmundch Feb 28, 2013
62985e0
Don't use package: imports in logging until dartdoc/mirros support them.
sigmundch Mar 1, 2013
fbfbc94
Moved pkg pubspecs to use dev_dependencies where appropriate
kevmoo Mar 20, 2013
f80f4b9
Make path to meta go through pkg/ , so that it's rewritten properly.
dgrove Mar 25, 2013
27d5ad8
pkg/logging: removed deprecated 'on' API
kevmoo Mar 27, 2013
f52ed0a
Switch pkg packages, pub, and dartdoc to use package: imports.
nex3 Mar 28, 2013
d06a26d
Remove StreamController.broadcast.
floitschG Apr 15, 2013
9fafd48
add installation instructions to pkg packages
sethladd Apr 19, 2013
685c91b
Make new StreamController be async by default.
lrhn May 31, 2013
4ed8407
add logging support for exceptions
sigmundch Jun 20, 2013
de38a7e
Make asBroadcastStream take two callbacks.
lrhn Jul 4, 2013
7c55991
Update meta and logging library descriptions; tweak fixnum
kwalrath Aug 22, 2013
64517e7
Add a toString() to LogRecord.
devoncarew Oct 7, 2013
7653e23
pkg/logging: added stackTrace support
kevmoo Oct 27, 2013
3f74838
Remove @deprecated features.
lrhn Oct 29, 2013
8e00240
Revert "Remove @deprecated features."
lrhn Oct 29, 2013
5c06cae
Add @proxy to annotations.dart.
lrhn Oct 30, 2013
4ec85e0
Reapply "Remove @deprecated features."
lrhn Oct 30, 2013
28a03cb
add useful docs for logging
sethladd Nov 1, 2013
dd83bc1
add versions and constraints for packages and samples
Nov 6, 2013
3b03578
Revert "add versions and constraints for packages and samples"
Nov 6, 2013
61739cb
Re-land r29957 (add versions and constraints for packages and samples…
dgrove Nov 6, 2013
7599a0b
Combine unmodifiable_collection package into collection_helpers.
lrhn Nov 19, 2013
8bbc732
pkg/logging: expose static sorted const list of all levels
kevmoo Nov 26, 2013
1ddb964
update pubspecs for pkg uploading
Dec 11, 2013
ecdaebe
add LICENSE AUTHORS PATENTS so we can publish
Dec 11, 2013
865af31
Create associated packages for the dart:collection and dart:async libs.
lrhn Dec 19, 2013
ba55eb6
flagging pkg/args and pkg/logging as dev+1
kevmoo Dec 27, 2013
26480d6
pkg/logging: use UnmodifiableMapView from dart:collection
kevmoo Jul 24, 2014
05bdd75
updated logging package to accept functions or other non-string objec…
jakemac53 Jul 25, 2014
b367687
Update the pubspec's homepage link.
nex3 Dec 19, 2014
f19d447
Make type signature consistent with class Object
jacob314 Dec 23, 2014
c0b3497
Adding a "zone" value to "class LogRecord"
mkustermann Jan 7, 2015
e6e65f6
Allow a greater range of types as a stack trace
Fox32 Apr 10, 2015
c66456d
Merge pull request dart-lang/logging#1 from Fox32/feature/stacktrace_…
Apr 10, 2015
77cc905
Revert change to make stackTrace object
kevmoo May 6, 2015
c6a6118
dartfmt
kevmoo Jan 13, 2015
36292c7
tweaked readme example
kevmoo Jan 13, 2015
972f7cc
move to test pkg
kevmoo May 6, 2015
d8ac950
ship 0.11.0
kevmoo May 6, 2015
f060bc8
Add option to automatically record stack trace in logging (fixes dart…
sigmundch May 7, 2015
083d3d2
Improve Logger.root (static final instead of getter that looks the ca…
ochafik Jul 1, 2015
d503357
Merge pull request dart-lang/logging#24 from ochafik/patch-1
sigmundch Jul 1, 2015
85d8c60
Also generate error when autogenerating stack traces (fix dart-lang/l…
sigmundch Aug 19, 2015
a7686ff
Add Logger.detached factory
astashov Sep 30, 2015
a6d5cfd
Merge pull request dart-lang/logging#27 from astashov/add-orphan-factory
sigmundch Oct 1, 2015
1c327a6
Add changelog entry
sigmundch Oct 1, 2015
b7807a9
save non-string object on LogRecord (dart-lang/logging#28)
jasonaguilon-wf Apr 18, 2016
22967da
dartfmt
kevmoo Jul 18, 2016
668275c
cleanup .gitignore
kevmoo Jul 18, 2016
beb4476
Fixing some doc comments
srawlins Jul 15, 2016
0d41cdc
Use correct config for pkg/test on bots
kevmoo Jan 24, 2017
a617f85
Enable travis, add analysis_options, other cleanup (dart-lang/logging…
kevmoo Oct 23, 2017
cb48b22
Allow chrome tests to fail (dart-lang/logging#37)
kevmoo Jan 18, 2018
af83904
Remove dartium from travis tests (dart-lang/logging#38)
kevmoo Feb 13, 2018
974c007
Delete PATENTS
kevmoo Mar 16, 2018
dc9d3f9
chore: set max SDK version to <3.0.0 (dart-lang/logging#40)
chalin Jul 18, 2018
5351247
Update to best practices in README
natebosch Sep 20, 2018
79cf597
Merge pull request dart-lang/logging#42 from dart-lang/readme-style
natebosch Sep 20, 2018
a8c0425
Update README.md
pq Oct 27, 2018
776e8ad
Update README.md
pq Oct 27, 2018
4937e03
Merge pull request dart-lang/logging#47 from dart-lang/travis-badge
pq Oct 27, 2018
898d4fa
Update README.md
pq Oct 27, 2018
34c0f56
Merge pull request dart-lang/logging#48 from dart-lang/pub-shield
pq Oct 27, 2018
343a55e
dartfmt --fix, update min SDK to 2.0.0
kevmoo Oct 27, 2018
b8e1b54
Enable a number of new lints
kevmoo Oct 27, 2018
a7288c3
Only test one browser
kevmoo Oct 27, 2018
f5caf23
minor cleanups (dart-lang/logging#50)
pq Oct 30, 2018
d1ec82a
Document default LogLevel (dart-lang/logging#58)
jonasfj Mar 12, 2019
a4cfb98
Test travis on oldest supported SDK (dart-lang/logging#59)
kevmoo Apr 29, 2019
194b953
Fix dartlang.org links and add a missing dartfmt lint (dart-lang/logg…
kevmoo Jun 18, 2019
03783e3
Refactor into mini-libraries (dart-lang/logging#64)
kevmoo Aug 2, 2019
0db7a07
Replace _rootLevel with root._level (dart-lang/logging#69)
jamesderlin Jan 10, 2020
14084f1
Add changelog entry for defaultLevel (dart-lang/logging#70)
natebosch Jan 11, 2020
fbe62b4
Make detached Loggers work regardless of hierarchicalLoggingEnabled (…
jamesderlin Jan 15, 2020
980b9ee
prepare to release 0.11.4 (dart-lang/logging#72)
jakemac53 Jan 16, 2020
a8750ab
Reference docs for message arguments (dart-lang/logging#77)
natebosch Mar 12, 2020
013f6c0
Delete .test_config
kevmoo Jul 29, 2020
8350442
Migrate to null safety (dart-lang/logging#82)
jakemac53 Aug 28, 2020
a7656b1
update sdk constraint to allow 2.11 dev (dart-lang/logging#84)
jakemac53 Sep 29, 2020
66eee20
Support Dart 2.11 (dart-lang/logging#85)
kevmoo Nov 3, 2020
f4f0b4c
final cleanup, prep null safety release (dart-lang/logging#86)
jakemac53 Nov 10, 2020
73005cc
typos (dart-lang/logging#87)
pq Nov 11, 2020
979df4f
remove redundant experiment (dart-lang/logging#88)
pq Nov 11, 2020
e1a5df4
remove publish_to: none (dart-lang/logging#90)
jakemac53 Nov 16, 2020
95e33aa
Migrate to GitHub Actions (dart-lang/logging#94)
athomas Feb 1, 2021
1d474a4
stable null safety release (dart-lang/logging#95)
jakemac53 Feb 5, 2021
37bdd56
List the log levels in the README (dart-lang/logging#97)
natebosch Mar 25, 2021
a7226fa
Update LICENSE (dart-lang/logging#98)
franklinyow Apr 2, 2021
e7ee3bc
Move from pedantic to lints package (dart-lang/logging#102)
natebosch Jul 22, 2021
ed5ce02
Add example, update description (dart-lang/logging#103)
mit-mit Sep 14, 2021
a0c2ff4
Enable the avoid_dynamic_calls lint (dart-lang/logging#112)
devoncarew Feb 16, 2022
d2d1f17
Add Logger.attachedLoggers to return the known Logger objects (dart-l…
powerb33 Feb 16, 2022
f10819b
Drop invariant_booleans from lints (dart-lang/logging#117)
kevmoo Jul 25, 2022
f5c9702
add file copyrights and misc changes (dart-lang/logging#119)
devoncarew Aug 30, 2022
361204d
update CI config (dart-lang/logging#121)
devoncarew Oct 5, 2022
46490c6
Create no-response.yml (dart-lang/logging#124)
devoncarew Dec 6, 2022
8c634ac
Add a check that throws if a logger name ends with '.' (dart-lang/log…
predatorx7 Dec 6, 2022
dac77f8
Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/logging#125)
dependabot[bot] Jan 3, 2023
58e6fe4
Move to new analyzer language settings (dart-lang/logging#126)
kevmoo Jan 9, 2023
1465611
add a publish script; prep to publish 1.1.1 (dart-lang/logging#128)
devoncarew Jan 26, 2023
5f86536
Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/logging#129)
dependabot[bot] Feb 1, 2023
9d5989a
Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/logging#130)
dependabot[bot] Feb 1, 2023
ddaeb56
Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/logging#134)
dependabot[bot] Apr 3, 2023
6d92fd8
Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/logging#133)
dependabot[bot] Apr 3, 2023
682f769
Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/logging#136)
dependabot[bot] May 8, 2023
0e7b4df
blast_repo fixes (dart-lang/logging#137)
devoncarew May 10, 2023
0f5e913
Logger `onLevelChanged` notification (dart-lang/logging#138)
desistefanova May 18, 2023
627428e
blast_repo fixes (dart-lang/logging#141)
devoncarew May 22, 2023
9b17272
blast_repo fixes (dart-lang/logging#142)
devoncarew May 22, 2023
0bb76e5
prep for release (dart-lang/logging#140)
jakemac53 May 23, 2023
4d6045e
Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/logging#144)
dependabot[bot] Jul 1, 2023
edaceeb
Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/logging#147)
dependabot[bot] Sep 1, 2023
da0bdae
Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/logging#148)
dependabot[bot] Oct 1, 2023
cc91899
Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/logging#149)
dependabot[bot] Oct 1, 2023
cccfda5
Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/logging#151)
dependabot[bot] Nov 1, 2023
f2c4229
Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/logging#150)
dependabot[bot] Nov 1, 2023
098675a
Bump actions/stale from 8.0.0 to 9.0.0 (dart-lang/logging#152)
dependabot[bot] Jan 1, 2024
bef87f3
blast_repo fixes (dart-lang/logging#154)
kevmoo Jan 18, 2024
b539ee9
Hierarchical logging documentation (dart-lang/logging#146)
craiglabenz Jan 18, 2024
2de688a
update min SDK and deps (dart-lang/logging#155)
kevmoo Jan 18, 2024
3f7c113
Bump dart-lang/setup-dart from 1.6.1 to 1.6.2 (dart-lang/logging#157)
dependabot[bot] Feb 1, 2024
3ae5f9a
Override empty stack traces for traced events (dart-lang/logging#158)
natebosch Mar 7, 2024
0ddcee3
Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/logging#160)
dependabot[bot] Apr 1, 2024
0e3dbb6
Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/logging#162)
dependabot[bot] May 1, 2024
8397ba0
Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/logging#161)
dependabot[bot] May 1, 2024
c4b8ecf
Add `topics` to `pubspec.yaml` (dart-lang/logging#164)
jonasfj May 30, 2024
eacc928
Bump actions/checkout from 4.1.4 to 4.1.6 (dart-lang/logging#166)
dependabot[bot] Jun 1, 2024
ddda561
Update `topics` in `pubspec.yaml` (dart-lang/logging#165)
szakarias Jun 4, 2024
8b5427b
Update lints dep, bump min SDK (dart-lang/logging#167)
kevmoo Jun 20, 2024
456e9e7
Bump actions/checkout from 4.1.6 to 4.1.7 (dart-lang/logging#168)
dependabot[bot] Jul 1, 2024
bba9edb
blast_repo fixes (dart-lang/logging#170)
kevmoo Jul 1, 2024
168f541
Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group…
dependabot[bot] Oct 1, 2024
77c93eb
Fix typo in README (dart-lang/logging#173)
lawther Oct 3, 2024
32a7c39
Merge package:logging into the core monorepo
mosuem Oct 16, 2024
bafb17e
Add issue template and other fixes
mosuem Oct 16, 2024
b3d67ea
Moving fixes
mosuem Oct 16, 2024
31caf59
Add license to example file
mosuem Oct 16, 2024
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
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/logging.md
mosuem marked this conversation as resolved.
Show resolved Hide resolved
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"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@
"package:fixnum":
- changed-files:
- any-glob-to-any-file: 'pkgs/fixnum/**'

"package:logging":
- changed-files:
- any-glob-to-any-file: 'pkgs/logging/**'
70 changes: 70 additions & 0 deletions .github/workflows/logging.yaml
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'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This repository is home to various Dart packages under the [dart.dev](https://pu
| [convert](pkgs/convert/) | Utilities for converting between data representations. | [![pub package](https://img.shields.io/pub/v/convert.svg)](https://pub.dev/packages/convert) |
| [crypto](pkgs/crypto/) | Implementations of SHA, MD5, and HMAC cryptographic functions. | [![pub package](https://img.shields.io/pub/v/crypto.svg)](https://pub.dev/packages/crypto) |
| [fixnum](pkgs/fixnum/) | Library for 32- and 64-bit signed fixed-width integers. | [![pub package](https://img.shields.io/pub/v/fixnum.svg)](https://pub.dev/packages/fixnum) |
| [logging](pkgs/logging/) | Provides APIs for debugging and error logging. | [![pub package](https://img.shields.io/pub/v/logging.svg)](https://pub.dev/packages/logging) |

## Publishing automation

Expand Down
3 changes: 3 additions & 0 deletions pkgs/logging/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dart_tool
.packages
pubspec.lock
10 changes: 10 additions & 0 deletions pkgs/logging/AUTHORS
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 <anton.astashov@gmail.com>
92 changes: 92 additions & 0 deletions pkgs/logging/CHANGELOG.md
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.
27 changes: 27 additions & 0 deletions pkgs/logging/LICENSE
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.
141 changes: 141 additions & 0 deletions pkgs/logging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
[![Dart CI](https://github.com/dart-lang/core/actions/workflows/logging.yaml/badge.svg)](https://github.com/dart-lang/core/actions/workflows/logging.yaml)
[![Pub](https://img.shields.io/pub/v/logging.svg)](https://pub.dev/packages/logging)
[![package publisher](https://img.shields.io/pub/publisher/logging.svg)](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 (√√)
```
Loading
Loading