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

Commit f6979e3

Browse files
powerb33natebosch
andauthored
Add Logger.attachedLoggers to return the known Logger objects (#110)
Co-authored-by: Nate Bosch <[email protected]>
1 parent dfbe88b commit f6979e3

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## 1.0.3-dev
1+
## 1.1.0
22

3+
* Add `Logger.attachedLoggers` which exposes all loggers created with the
4+
default constructor.
35
* Enable the `avoid_dynamic_calls` lint.
46

57
## 1.0.2

lib/src/logger.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ class Logger {
5151
/// root [Logger].
5252
StreamController<LogRecord>? _controller;
5353

54-
/// Singleton constructor. Calling `new Logger(name)` will return the same
55-
/// actual instance whenever it is called with the same string name.
54+
/// Create or find a Logger by name.
55+
///
56+
/// Calling `Logger(name)` will return the same instance whenever it is called
57+
/// with the same string name. Loggers created with this constructor are
58+
/// retained indefinitely and available through [attachedLoggers];
5659
factory Logger(String name) =>
5760
_loggers.putIfAbsent(name, () => Logger._named(name));
5861

@@ -278,6 +281,11 @@ class Logger {
278281
/// Top-level root [Logger].
279282
static final Logger root = Logger('');
280283

281-
/// All [Logger]s in the system.
284+
/// All attached [Logger]s in the system.
282285
static final Map<String, Logger> _loggers = <String, Logger>{};
286+
287+
/// All attached [Logger]s in the system.
288+
///
289+
/// Loggers created with [Logger.detached] are not included.
290+
static Iterable<Logger> get attachedLoggers => _loggers.values;
283291
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: logging
2-
version: 1.0.3-dev
2+
version: 1.1.0
33

44
description: >-
55
Provides APIs for debugging and error logging, similar to loggers in other

0 commit comments

Comments
 (0)