dartfmt
diff --git a/lib/logging.dart b/lib/logging.dart
index 42344e8..7654885 100644
--- a/lib/logging.dart
+++ b/lib/logging.dart
@@ -21,7 +21,6 @@
*/
Level _rootLevel = Level.INFO;
-
/**
* Use a [Logger] to log debug messages. [Logger]s are named using a
* hierarchical dot-separated name convention.
@@ -74,9 +73,9 @@
return new Logger._internal(thisName, parent, new Map<String, Logger>());
}
- Logger._internal(this.name, this.parent, Map<String, Logger> children) :
- this._children = children,
- this.children = new UnmodifiableMapView(children) {
+ Logger._internal(this.name, this.parent, Map<String, Logger> children)
+ : this._children = children,
+ this.children = new UnmodifiableMapView(children) {
if (parent != null) parent._children[name] = this;
}
@@ -145,9 +144,8 @@
* different zones differently (e.g. group log records by http-request if each
* http-request handler runs in it's own zone).
*/
- void log(Level logLevel,
- message,
- [Object error, StackTrace stackTrace, Zone zone]) {
+ void log(Level logLevel, message,
+ [Object error, StackTrace stackTrace, Zone zone]) {
if (isLoggable(logLevel)) {
// If message is a Function, evaluate it.
if (message is Function) message = message();
@@ -156,8 +154,8 @@
// Only record the current zone if it was not given.
if (zone == null) zone = Zone.current;
- var record = new LogRecord(logLevel, message, fullName, error,
- stackTrace, zone);
+ var record =
+ new LogRecord(logLevel, message, fullName, error, stackTrace, zone);
if (hierarchicalLoggingEnabled) {
var target = this;
@@ -227,7 +225,6 @@
static final Map<String, Logger> _loggers = <String, Logger>{};
}
-
/** Handler callback to process log entries as they are added to a [Logger]. */
typedef void LoggerHandler(LogRecord);
@@ -244,7 +241,6 @@
* [Level.OFF].
*/
class Level implements Comparable<Level> {
-
final String name;
/**
@@ -285,8 +281,18 @@
/** 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];
+ static const List<Level> LEVELS = const [
+ ALL,
+ FINEST,
+ FINER,
+ FINE,
+ CONFIG,
+ INFO,
+ WARNING,
+ SEVERE,
+ SHOUT,
+ OFF
+ ];
bool operator ==(other) => other is Level && value == other.value;
bool operator <(Level other) => value < other.value;
@@ -298,7 +304,6 @@
String toString() => name;
}
-
/**
* A log entry representation used to propagate information from [Logger] to
* individual [Handler]s.
@@ -327,9 +332,8 @@
/** Zone of the calling code which resulted in this LogRecord. */
final Zone zone;
- LogRecord(this.level, this.message, this.loggerName, [this.error,
- this.stackTrace,
- this.zone])
+ LogRecord(this.level, this.message, this.loggerName,
+ [this.error, this.stackTrace, this.zone])
: time = new DateTime.now(),
sequenceNumber = LogRecord._nextNumber++;
diff --git a/test/logging_test.dart b/test/logging_test.dart
index 8eb116a..2162254 100644
--- a/test/logging_test.dart
+++ b/test/logging_test.dart
@@ -2,7 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-
library logging_test;
import 'dart:async';
@@ -42,9 +41,17 @@
test('levels are comparable', () {
final unsorted = [
- Level.INFO, Level.CONFIG, Level.FINE, Level.SHOUT, Level.OFF,
- Level.FINER, Level.ALL, Level.WARNING, Level.FINEST, Level.SEVERE,
- ];
+ Level.INFO,
+ Level.CONFIG,
+ Level.FINE,
+ Level.SHOUT,
+ Level.OFF,
+ Level.FINER,
+ Level.ALL,
+ Level.WARNING,
+ Level.FINEST,
+ Level.SEVERE,
+ ];
final sorted = Level.LEVELS;
@@ -112,7 +119,7 @@
expect(loggerA.children['b'], same(loggerAB), reason: 'can read Children');
expect(() {
- loggerAB.children['test'] = null;
+ loggerAB.children['test'] = null;
}, throwsUnsupportedError, reason: 'Children is read-only');
});
@@ -125,7 +132,7 @@
try {
throw new UnsupportedError('test exception');
- } catch(error, stack) {
+ } catch (error, stack) {
Logger.root.log(Level.SEVERE, 'severe', error, stack);
Logger.root.warning('warning', error, stack);
}
@@ -226,7 +233,9 @@
});
test('cannot set level if hierarchy is disabled', () {
- expect(() {a.level = Level.FINE;}, throwsUnsupportedError);
+ expect(() {
+ a.level = Level.FINE;
+ }, throwsUnsupportedError);
});
test('loggers effective level - no hierarchy', () {
@@ -273,7 +282,9 @@
test('add/remove handlers - no hierarchy', () {
int calls = 0;
- var handler = (_) { calls++; };
+ var handler = (_) {
+ calls++;
+ };
final sub = c.onRecord.listen(handler);
root.info("foo");
root.info("foo");
@@ -286,7 +297,9 @@
test('add/remove handlers - with hierarchy', () {
hierarchicalLoggingEnabled = true;
int calls = 0;
- var handler = (_) { calls++; };
+ var handler = (_) {
+ calls++;
+ };
c.onRecord.listen(handler);
root.info("foo");
root.info("foo");
@@ -317,7 +330,8 @@
'INFO: 5',
'WARNING: 6',
'SEVERE: 7',
- 'SHOUT: 8']));
+ 'SHOUT: 8'
+ ]));
});
test('logging methods store exception', () {
@@ -360,7 +374,8 @@
'INFO: 5 e',
'WARNING: 6 f',
'SEVERE: 7 g',
- 'SHOUT: 8 h']));
+ 'SHOUT: 8 h'
+ ]));
});
test('message logging - no hierarchy', () {
@@ -392,16 +407,17 @@
c.shout('10');
expect(rootMessages, equals([
- // 'INFO: 1' is not loggable
- // 'FINE: 2' is not loggable
- 'SHOUT: 3',
- // 'INFO: 4' is not loggable
- 'SEVERE: 5',
- 'WARNING: 6',
- // 'FINE: 7' is not loggable
- // 'FINE: 8' is not loggable
- 'WARNING: 9',
- 'SHOUT: 10']));
+ // 'INFO: 1' is not loggable
+ // 'FINE: 2' is not loggable
+ 'SHOUT: 3',
+ // 'INFO: 4' is not loggable
+ 'SEVERE: 5',
+ 'WARNING: 6',
+ // 'FINE: 7' is not loggable
+ // 'FINE: 8' is not loggable
+ 'WARNING: 9',
+ 'SHOUT: 10'
+ ]));
// no hierarchy means we all hear the same thing.
expect(aMessages, equals(rootMessages));
@@ -440,32 +456,35 @@
c.shout('10');
expect(rootMessages, equals([
- 'INFO: 1',
- // 'FINE: 2' is not loggable
- 'SHOUT: 3',
- // 'INFO: 4' is not loggable
- 'SEVERE: 5',
- 'WARNING: 6',
- // 'FINE: 7' is not loggable
- // 'FINE: 8' is not loggable
- 'WARNING: 9',
- 'SHOUT: 10']));
+ 'INFO: 1',
+ // 'FINE: 2' is not loggable
+ 'SHOUT: 3',
+ // 'INFO: 4' is not loggable
+ 'SEVERE: 5',
+ 'WARNING: 6',
+ // 'FINE: 7' is not loggable
+ // 'FINE: 8' is not loggable
+ 'WARNING: 9',
+ 'SHOUT: 10'
+ ]));
expect(aMessages, equals([
- // 1,2 and 3 are lower in the hierarchy
- // 'INFO: 4' is not loggable
- 'SEVERE: 5',
- 'WARNING: 6',
- // 'FINE: 7' is not loggable
- // 'FINE: 8' is not loggable
- 'WARNING: 9',
- 'SHOUT: 10']));
+ // 1,2 and 3 are lower in the hierarchy
+ // 'INFO: 4' is not loggable
+ 'SEVERE: 5',
+ 'WARNING: 6',
+ // 'FINE: 7' is not loggable
+ // 'FINE: 8' is not loggable
+ 'WARNING: 9',
+ 'SHOUT: 10'
+ ]));
expect(cMessages, equals([
- // 1 - 7 are lower in the hierarchy
- // 'FINE: 8' is not loggable
- 'WARNING: 9',
- 'SHOUT: 10']));
+ // 1 - 7 are lower in the hierarchy
+ // 'FINE: 8' is not loggable
+ 'WARNING: 9',
+ 'SHOUT: 10'
+ ]));
});
test('message logging - lazy functions', () {
@@ -479,12 +498,10 @@
var myClosure = () => "${++callCount}";
root.info(myClosure);
- root.finer(myClosure); // Should not get evaluated.
+ root.finer(myClosure); // Should not get evaluated.
root.warning(myClosure);
- expect(messages, equals([
- 'INFO: 1',
- 'WARNING: 2',]));
+ expect(messages, equals(['INFO: 1', 'WARNING: 2',]));
});
test('message logging - calls toString', () {
@@ -499,11 +516,8 @@
root.info([1, 2, 3]);
root.info(() => 10);
- expect(messages, equals([
- 'INFO: 5',
- 'INFO: false',
- 'INFO: [1, 2, 3]',
- 'INFO: 10',]));
+ expect(messages,
+ equals(['INFO: 5', 'INFO: false', 'INFO: [1, 2, 3]', 'INFO: 10',]));
});
});
}