pkg/logging: expose static sorted const list of all levels
BUG= https://code.google.com/p/dart/issues/detail?id=15321
R=sigmund@google.com
Review URL: https://codereview.chromium.org//88323004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@30676 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/logging.dart b/lib/logging.dart
index 37ac67d..8bff36b 100644
--- a/lib/logging.dart
+++ b/lib/logging.dart
@@ -311,6 +311,9 @@
/** Key for extra debugging loudness ([value] = 1200). */
static const Level SHOUT = const Level('SHOUT', 1200);
+ static const List<Level> LEVELS = const
+ [ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, SHOUT, OFF];
+
bool operator ==(Object other) => other is Level && value == other.value;
bool operator <(Level other) => value < other.value;
bool operator <=(Level other) => value <= other.value;
diff --git a/pubspec.yaml b/pubspec.yaml
index d298608..334113f 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,12 +1,12 @@
name: logging
-version: 0.9.0
+version: 0.9.1-dev
author: Dart Team <misc@dartlang.org>
description: Provides APIs for debugging and error logging. This library introduces abstractions similar to those used in other languages, such as the Closure JS Logger and java.util.logging.Logger.
homepage: http://www.dartlang.org
documentation: http://api.dartlang.org/docs/pkg/logging
-dependencies:
- collection_helpers: ">=0.9.0 <0.10.0"
-dev_dependencies:
- unittest: ">=0.9.0 <0.10.0"
environment:
- sdk: ">=0.8.10+6 <2.0.0"
+ sdk: '>=0.8.10+6 <2.0.0'
+dependencies:
+ collection_helpers: '>=0.9.1 <0.10.0'
+dev_dependencies:
+ unittest: '>=0.9.0 <0.10.0'
diff --git a/test/logging_test.dart b/test/logging_test.dart
index a188bb5..82ef3e1 100644
--- a/test/logging_test.dart
+++ b/test/logging_test.dart
@@ -29,10 +29,7 @@
});
test('default levels are in order', () {
- final levels = const [
- Level.ALL, Level.FINEST, Level.FINER, Level.FINE, Level.CONFIG,
- Level.INFO, Level.WARNING, Level.SEVERE, Level.SHOUT, Level.OFF
- ];
+ final levels = Level.LEVELS;
for (int i = 0; i < levels.length; i++) {
for (int j = i + 1; j < levels.length; j++) {
@@ -46,13 +43,12 @@
Level.INFO, Level.CONFIG, Level.FINE, Level.SHOUT, Level.OFF,
Level.FINER, Level.ALL, Level.WARNING, Level.FINEST, Level.SEVERE,
];
- final sorted = const [
- Level.ALL, Level.FINEST, Level.FINER, Level.FINE, Level.CONFIG,
- Level.INFO, Level.WARNING, Level.SEVERE, Level.SHOUT, Level.OFF
- ];
+
+ final sorted = Level.LEVELS;
+
expect(unsorted, isNot(orderedEquals(sorted)));
- unsorted.sort((a, b) => a.compareTo(b));
+ unsorted.sort();
expect(unsorted, orderedEquals(sorted));
});
@@ -65,7 +61,7 @@
});
test('logger name cannot start with a "." ', () {
- expect(() => new Logger('.c'), throws);
+ expect(() => new Logger('.c'), throwsArgumentError);
});
test('logger naming is hierarchical', () {