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

Commit 0373ef8

Browse files
authored
Add a check that throws if a logger name ends with '.' (#123)
1 parent 6d46d71 commit 0373ef8

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.1-dev
2+
3+
* Add a check that throws if a logger name ends with '.'.
4+
15
## 1.1.0
26

37
* Add `Logger.attachedLoggers` which exposes all loggers created with the

lib/src/logger.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ class Logger {
7878
if (name.startsWith('.')) {
7979
throw ArgumentError("name shouldn't start with a '.'");
8080
}
81+
if (name.endsWith('.')) {
82+
throw ArgumentError("name shouldn't end with a '.'");
83+
}
84+
8185
// Split hierarchical names (separated with '.').
8286
var dot = name.lastIndexOf('.');
8387
Logger? parent;

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.1.0
2+
version: 1.1.1-dev
33

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

test/logging_test.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ void main() {
7575
expect(() => Logger('.c'), throwsArgumentError);
7676
});
7777

78+
test('logger name cannot end with a "."', () {
79+
expect(() => Logger('a.'), throwsArgumentError);
80+
expect(() => Logger('a..d'), throwsArgumentError);
81+
});
82+
7883
test('root level has proper defaults', () {
7984
expect(Logger.root, isNotNull);
8085
expect(Logger.root.parent, null);

0 commit comments

Comments
 (0)