From 478291f4520f019d3bc92b7024a9e572358f3e9c Mon Sep 17 00:00:00 2001 From: "alanknight@google.com" Date: Tue, 14 Aug 2012 23:05:20 +0000 Subject: [PATCH 001/163] Move tests for things in /pkg into the right places for packages Review URL: https://chromiumcodereview.appspot.com//10828310 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@10688 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/logging.dart | 334 ++++++++++++++++++++++++++ pkgs/logging/pubspec.yaml | 9 + pkgs/logging/tests/logging_test.dart | 336 +++++++++++++++++++++++++++ 3 files changed, 679 insertions(+) create mode 100644 pkgs/logging/logging.dart create mode 100644 pkgs/logging/pubspec.yaml create mode 100644 pkgs/logging/tests/logging_test.dart diff --git a/pkgs/logging/logging.dart b/pkgs/logging/logging.dart new file mode 100644 index 00000000..c489fddd --- /dev/null +++ b/pkgs/logging/logging.dart @@ -0,0 +1,334 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// 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. + +/** + * 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. + */ +#library('logging'); + +/** + * Whether to allow fine-grain logging and configuration of loggers in a + * hierarchy. When false, all logging is merged in the root logger. + */ +bool hierarchicalLoggingEnabled = false; + +/** + * Level for the root-logger. This will be the level of all loggers if + * [hierarchicalLoggingEnabled] is false. + */ +Level _rootLevel = Level.INFO; + + +/** + * Use a [Logger] to log debug messages. [Logger]s are named using a + * hierarchical dot-separated name convention. + */ +class Logger { + /** Simple name of this logger. */ + final String name; + + /** The full name of this logger, which includes the parent's full name. */ + String get fullName() => + (parent == null || parent.name == '') ? name : '${parent.fullName}.$name'; + + /** Parent of this logger in the hierarchy of loggers. */ + final Logger parent; + + /** Logging [Level] used for entries generated on this logger. */ + Level _level; + + /** Children in the hierarchy of loggers, indexed by their simple names. */ + Map children; + + /** Handlers used to process log entries in this logger. */ + List _handlers; + + /** + * Singleton constructor. Calling `new Logger(name)` will return the same + * actual instance whenever it is called with the same string name. + */ + factory Logger(String name) { + if (name.startsWith('.')) { + throw new IllegalArgumentException("name shouldn't start with a '.'"); + } + if (_loggers == null) _loggers = {}; + if (_loggers.containsKey(name)) return _loggers[name]; + + // Split hierarchical names (separated with '.'). + int dot = name.lastIndexOf('.'); + Logger parent = null; + String thisName; + if (dot == -1) { + if (name != '') parent = new Logger(''); + thisName = name; + } else { + parent = new Logger(name.substring(0, dot)); + thisName = name.substring(dot + 1); + } + final res = new Logger._internal(thisName, parent); + _loggers[name] = res; + return res; + } + + Logger._internal(this.name, this.parent) + : children = new Map() { + if (parent != null) parent.children[name] = this; + } + + /** + * Effective level considering the levels established in this logger's parents + * (when [hierarchicalLoggingEnabled] is true). + */ + Level get level() { + if (hierarchicalLoggingEnabled) { + if (_level != null) return _level; + if (parent != null) return parent.level; + } + return _rootLevel; + } + + /** Override the level for this particular [Logger] and its children. */ + Level set level(value) { + if (hierarchicalLoggingEnabled && parent != null) { + _level = value; + } else { + if (parent != null) { + throw new UnsupportedOperationException( + 'Please set "hierarchicalLoggingEnabled" to true if you want to ' + 'change the level on a non-root logger.'); + } + _rootLevel = value; + } + } + + /** + * Returns an event manager for this [Logger]. You can listen for log messages + * by adding a [LoggerHandler] to an event from the event manager, for + * instance: + * logger.on.record.add((record) { ... }); + */ + LoggerEvents get on() => new LoggerEvents(this); + + /** Adds a handler to listen whenever a log record is added to this logger. */ + void _addHandler(LoggerHandler handler) { + if (hierarchicalLoggingEnabled || parent == null) { + if (_handlers == null) { + _handlers = new List(); + } + _handlers.add(handler); + } else { + root._addHandler(handler); + } + } + + /** Remove a previously added handler. */ + void _removeHandler(LoggerHandler handler) { + if (hierarchicalLoggingEnabled || parent == null) { + if (_handlers == null) return; + int index = _handlers.indexOf(handler); + if (index != -1) _handlers.removeRange(index, 1); + } else { + root._removeHandler(handler); + } + } + + /** Removes all handlers previously added to this logger. */ + void _clearHandlers() { + if (hierarchicalLoggingEnabled || parent == null) { + _handlers = null; + } else { + root._clearHandlers(); + } + } + + /** Whether a message for [value]'s level is loggable in this logger. */ + bool isLoggable(Level value) => (value >= level); + + /** + * Adds a log record for a [message] at a particular [logLevel] if + * `isLoggable(logLevel)` is true. Use this method to create log entries for + * user-defined levels. To record a message at a predefined level (e.g. + * [Level.INFO], [Level.WARNING], etc) you can use their specialized methods + * instead (e.g. [info], [warning], etc). + */ + // TODO(sigmund): add support for logging exceptions. + void log(Level logLevel, String message) { + if (isLoggable(logLevel)) { + var record = new LogRecord(logLevel, message, fullName); + if (hierarchicalLoggingEnabled) { + var target = this; + while (target != null) { + target._publish(record); + target = target.parent; + } + } else { + root._publish(record); + } + } + } + + /** Log message at level [Level.FINEST]. */ + void finest(String message) => log(Level.FINEST, message); + + /** Log message at level [Level.FINER]. */ + void finer(String message) => log(Level.FINER, message); + + /** Log message at level [Level.FINE]. */ + void fine(String message) => log(Level.FINE, message); + + /** Log message at level [Level.CONFIG]. */ + void config(String message) => log(Level.CONFIG, message); + + /** Log message at level [Level.INFO]. */ + void info(String message) => log(Level.INFO, message); + + /** Log message at level [Level.WARNING]. */ + void warning(String message) => log(Level.WARNING, message); + + /** Log message at level [Level.SEVERE]. */ + void severe(String message) => log(Level.SEVERE, message); + + /** Log message at level [Level.SHOUT]. */ + void shout(String message) => log(Level.SHOUT, message); + + void _publish(LogRecord record) { + if (_handlers != null) { + _handlers.forEach((h) => h(record)); + } + } + + /** Top-level root [Logger]. */ + static get root() => new Logger(''); + + /** All [Logger]s in the system. */ + static Map _loggers; +} + + +/** Handler callback to process log entries as they are added to a [Logger]. */ +typedef void LoggerHandler(LogRecord); + + +/** Event manager for a [Logger] (holds events that a [Logger] can fire). */ +class LoggerEvents { + final Logger _logger; + + LoggerEvents(this._logger); + + /** Event fired when a log record is added to a [Logger]. */ + LoggerHandlerList get record() => new LoggerHandlerList(_logger); +} + + +/** List of handlers that will be called on a logger event. */ +class LoggerHandlerList { + Logger _logger; + + LoggerHandlerList(this._logger); + + void add(LoggerHandler handler) => _logger._addHandler(handler); + void remove(LoggerHandler handler) => _logger._removeHandler(handler); + void clear() => _logger._clearHandlers(); +} + + +/** + * [Level]s to control logging output. Logging can be enabled to include all + * levels above certain [Level]. [Level]s are ordered using an integer + * value [Level.value]. The predefined [Level] constants below are sorted as + * follows (in descending order): [Level.SHOUT], [Level.SEVERE], + * [Level.WARNING], [Level.INFO], [Level.CONFIG], [Level.FINE], [Level.FINER], + * [Level.FINEST], and [Level.ALL]. + * + * We recommend using one of the predefined logging levels. If you define your + * own level, make sure you use a value between those used in [Level.ALL] and + * [Level.OFF]. + */ +class Level implements Comparable, Hashable { + + // TODO(sigmund): mark name/value as 'const' when the language supports it. + final String name; + + /** + * Unique value for this level. Used to order levels, so filtering can exclude + * messages whose level is under certain value. + */ + final int value; + + const Level(this.name, this.value); + + /** Special key to turn on logging for all levels ([value] = 0). */ + static final Level ALL = const Level('ALL', 0); + + /** Special key to turn off all logging ([value] = 2000). */ + static final Level OFF = const Level('OFF', 2000); + + /** Key for highly detailed tracing ([value] = 300). */ + static final Level FINEST = const Level('FINEST', 300); + + /** Key for fairly detailed tracing ([value] = 400). */ + static final Level FINER = const Level('FINER', 400); + + /** Key for tracing information ([value] = 500). */ + static final Level FINE = const Level('FINE', 500); + + /** Key for static configuration messages ([value] = 700). */ + static final Level CONFIG = const Level('CONFIG', 700); + + /** Key for informational messages ([value] = 800). */ + static final Level INFO = const Level('INFO', 800); + + /** Key for potential problems ([value] = 900). */ + static final Level WARNING = const Level('WARNING', 900); + + /** Key for serious failures ([value] = 1000). */ + static final Level SEVERE = const Level('SEVERE', 1000); + + /** Key for extra debugging loudness ([value] = 1200). */ + static final Level SHOUT = const Level('SHOUT', 1200); + + bool operator ==(Level other) => other != null && value == other.value; + bool operator <(Level other) => value < other.value; + bool operator <=(Level other) => value <= other.value; + bool operator >(Level other) => value > other.value; + bool operator >=(Level other) => value >= other.value; + int compareTo(Level other) => value - other.value; + int hashCode() => value; + String toString() => name; +} + + +/** + * A log entry representation used to propagate information from [Logger] to + * individual [Handler]s. + */ +class LogRecord { + final Level level; + final String message; + + /** Logger where this record is stored. */ + final String loggerName; + + /** Time when this record was created. */ + final Date time; + + /** Unique sequence number greater than all log records created before it. */ + final int sequenceNumber; + + static int _nextNumber = 0; + + /** Associated exception (if any) when recording errors messages. */ + Exception exception; + + /** Associated exception message (if any) when recording errors messages. */ + String exceptionText; + + LogRecord( + this.level, this.message, this.loggerName, + [time, this.exception, this.exceptionText]) : + this.time = (time == null) ? new Date.now() : time, + this.sequenceNumber = LogRecord._nextNumber++; +} diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml new file mode 100644 index 00000000..4a7e068c --- /dev/null +++ b/pkgs/logging/pubspec.yaml @@ -0,0 +1,9 @@ +name: logging +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. + +dependencies: + unittest: + sdk: unittest diff --git a/pkgs/logging/tests/logging_test.dart b/pkgs/logging/tests/logging_test.dart new file mode 100644 index 00000000..66688100 --- /dev/null +++ b/pkgs/logging/tests/logging_test.dart @@ -0,0 +1,336 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// 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('../logging.dart'); +#import('../../../pkg/unittest/unittest.dart'); + +main() { + test('level comparison is a valid comparator', () { + var level1 = const Level('NOT_REAL1', 253); + expect(level1 == level1); + expect(level1 <= level1); + expect(level1 >= level1); + expect(level1 < level1, isFalse); + expect(level1 > level1, isFalse); + + var level2 = const Level('NOT_REAL2', 455); + expect(level1 <= level2); + expect(level1 < level2); + expect(level2 >= level1); + expect(level2 > level1); + + var level3 = const Level('NOT_REAL3', 253); + expect(level1 !== level3); // different instances + expect(level1 == level3); // same value. + }); + + 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 + ]; + + for (int i = 0; i < levels.length; i++) { + for (int j = i + 1; j < levels.length; j++) { + expect(levels[i] < levels[j]); + } + } + }); + + 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, + ]; + final sorted = const [ + Level.ALL, Level.FINEST, Level.FINER, Level.FINE, Level.CONFIG, + Level.INFO, Level.WARNING, Level.SEVERE, Level.SHOUT, Level.OFF + ]; + expect(unsorted, isNot(orderedEquals(sorted))); + + unsorted.sort((a, b) => a.compareTo(b)); + expect(unsorted, orderedEquals(sorted)); + }); + + test('levels are hashable', () { + var map = new Map(); + map[Level.INFO] = 'info'; + map[Level.SHOUT] = 'shout'; + expect(map[Level.INFO], equals('info')); + expect(map[Level.SHOUT], equals('shout')); + }); + + test('logger name cannot start with a "." ', () { + expect(() => new Logger('.c'), throws); + }); + + test('logger naming is hierarchical', () { + Logger c = new Logger('a.b.c'); + expect(c.name, equals('c')); + expect(c.parent.name, equals('b')); + expect(c.parent.parent.name, equals('a')); + expect(c.parent.parent.parent.name, equals('')); + expect(c.parent.parent.parent.parent, isNull); + }); + + test('logger full name', () { + Logger c = new Logger('a.b.c'); + expect(c.fullName, equals('a.b.c')); + expect(c.parent.fullName, equals('a.b')); + expect(c.parent.parent.fullName, equals('a')); + expect(c.parent.parent.parent.fullName, equals('')); + expect(c.parent.parent.parent.parent, isNull); + }); + + test('logger parent-child links are correct', () { + Logger a = new Logger('a'); + Logger b = new Logger('a.b'); + Logger c = new Logger('a.c'); + expect(a == b.parent); + expect(a == c.parent); + expect(a.children['b'] == b); + expect(a.children['c'] == c); + }); + + test('loggers are singletons', () { + Logger a1 = new Logger('a'); + Logger a2 = new Logger('a'); + Logger b = new Logger('a.b'); + Logger root = Logger.root; + expect(a1 === a2); + expect(a1 === b.parent); + expect(root === a1.parent); + expect(root === new Logger('')); + }); + + group('mutating levels', () { + Logger root = Logger.root; + Logger a = new Logger('a'); + Logger b = new Logger('a.b'); + Logger c = new Logger('a.b.c'); + Logger d = new Logger('a.b.c.d'); + Logger e = new Logger('a.b.c.d.e'); + + setUp(() { + hierarchicalLoggingEnabled = true; + root.level = Level.INFO; + a.level = null; + b.level = null; + c.level = null; + d.level = null; + e.level = null; + root.on.record.clear(); + a.on.record.clear(); + b.on.record.clear(); + c.on.record.clear(); + d.on.record.clear(); + e.on.record.clear(); + hierarchicalLoggingEnabled = false; + root.level = Level.INFO; + }); + + test('cannot set level if hierarchy is disabled', () { + expect(() {a.level = Level.FINE;}, throws); + }); + + test('loggers effective level - no hierarchy', () { + expect(root.level, equals(Level.INFO)); + expect(a.level, equals(Level.INFO)); + expect(b.level, equals(Level.INFO)); + + root.level = Level.SHOUT; + + expect(root.level, equals(Level.SHOUT)); + expect(a.level, equals(Level.SHOUT)); + expect(b.level, equals(Level.SHOUT)); + }); + + test('loggers effective level - with hierarchy', () { + hierarchicalLoggingEnabled = true; + expect(root.level, equals(Level.INFO)); + expect(a.level, equals(Level.INFO)); + expect(b.level, equals(Level.INFO)); + expect(c.level, equals(Level.INFO)); + + root.level = Level.SHOUT; + b.level = Level.FINE; + + expect(root.level, equals(Level.SHOUT)); + expect(a.level, equals(Level.SHOUT)); + expect(b.level, equals(Level.FINE)); + expect(c.level, equals(Level.FINE)); + }); + + test('isLoggable is appropriate', () { + hierarchicalLoggingEnabled = true; + root.level = Level.SEVERE; + c.level = Level.ALL; + e.level = Level.OFF; + + expect(root.isLoggable(Level.SHOUT)); + expect(root.isLoggable(Level.SEVERE)); + expect(!root.isLoggable(Level.WARNING)); + expect(c.isLoggable(Level.FINEST)); + expect(c.isLoggable(Level.FINE)); + expect(!e.isLoggable(Level.SHOUT)); + }); + + test('add/remove handlers - no hierarchy', () { + int calls = 0; + var handler = (_) { calls++; }; + c.on.record.add(handler); + root.info("foo"); + root.info("foo"); + expect(calls, equals(2)); + c.on.record.remove(handler); + root.info("foo"); + expect(calls, equals(2)); + }); + + test('add/remove handlers - with hierarchy', () { + hierarchicalLoggingEnabled = true; + int calls = 0; + var handler = (_) { calls++; }; + c.on.record.add(handler); + root.info("foo"); + root.info("foo"); + expect(calls, equals(0)); + }); + + test('logging methods store appropriate level', () { + root.level = Level.ALL; + var rootMessages = []; + root.on.record.add((record) { + rootMessages.add('${record.level}: ${record.message}'); + }); + + root.finest('1'); + root.finer('2'); + root.fine('3'); + root.config('4'); + root.info('5'); + root.warning('6'); + root.severe('7'); + root.shout('8'); + + expect(rootMessages, equals([ + 'FINEST: 1', + 'FINER: 2', + 'FINE: 3', + 'CONFIG: 4', + 'INFO: 5', + 'WARNING: 6', + 'SEVERE: 7', + 'SHOUT: 8'])); + }); + + test('message logging - no hierarchy', () { + root.level = Level.WARNING; + var rootMessages = []; + var aMessages = []; + var cMessages = []; + c.on.record.add((record) { + cMessages.add('${record.level}: ${record.message}'); + }); + a.on.record.add((record) { + aMessages.add('${record.level}: ${record.message}'); + }); + root.on.record.add((record) { + rootMessages.add('${record.level}: ${record.message}'); + }); + + root.info('1'); + root.fine('2'); + root.shout('3'); + + b.info('4'); + b.severe('5'); + b.warning('6'); + b.fine('7'); + + c.fine('8'); + c.warning('9'); + 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'])); + + // no hierarchy means we all hear the same thing. + expect(aMessages, equals(rootMessages)); + expect(cMessages, equals(rootMessages)); + }); + + test('message logging - with hierarchy', () { + hierarchicalLoggingEnabled = true; + + b.level = Level.WARNING; + + var rootMessages = []; + var aMessages = []; + var cMessages = []; + c.on.record.add((record) { + cMessages.add('${record.level}: ${record.message}'); + }); + a.on.record.add((record) { + aMessages.add('${record.level}: ${record.message}'); + }); + root.on.record.add((record) { + rootMessages.add('${record.level}: ${record.message}'); + }); + + root.info('1'); + root.fine('2'); + root.shout('3'); + + b.info('4'); + b.severe('5'); + b.warning('6'); + b.fine('7'); + + c.fine('8'); + c.warning('9'); + 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'])); + + 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'])); + + expect(cMessages, equals([ + // 1 - 7 are lower in the hierarchy + // 'FINE: 8' is not loggable + 'WARNING: 9', + 'SHOUT: 10'])); + }); + }); +} From aac41970ab5c2025f3dd6bf53d44ccd4090e5150 Mon Sep 17 00:00:00 2001 From: "alanknight@google.com" Date: Wed, 15 Aug 2012 21:38:41 +0000 Subject: [PATCH 002/163] Rename "tests" directories under /pkg to the singular "test" Review URL: https://chromiumcodereview.appspot.com//10837268 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@10771 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/{tests => test}/logging_test.dart | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pkgs/logging/{tests => test}/logging_test.dart (100%) diff --git a/pkgs/logging/tests/logging_test.dart b/pkgs/logging/test/logging_test.dart similarity index 100% rename from pkgs/logging/tests/logging_test.dart rename to pkgs/logging/test/logging_test.dart From 8a3028b53dd5f24d651f03f81a911b4ab59b0741 Mon Sep 17 00:00:00 2001 From: "regis@google.com" Date: Thu, 16 Aug 2012 20:44:32 +0000 Subject: [PATCH 003/163] Require two type arguments for map literals (issue 4522). Spec has been changed back. VM temporarily accepts a single type argument and emits a warning. Update tests, dart2js source, dartdoc, etc... Disable failing co19 tests (issue 175 filed). Review URL: https://chromiumcodereview.appspot.com//10854191 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@10861 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/logging.dart b/pkgs/logging/logging.dart index c489fddd..e81ef71f 100644 --- a/pkgs/logging/logging.dart +++ b/pkgs/logging/logging.dart @@ -54,7 +54,7 @@ class Logger { if (name.startsWith('.')) { throw new IllegalArgumentException("name shouldn't start with a '.'"); } - if (_loggers == null) _loggers = {}; + if (_loggers == null) _loggers = {}; if (_loggers.containsKey(name)) return _loggers[name]; // Split hierarchical names (separated with '.'). From e839b3ac0850276bd83b2a9828888e5a26c6a4c2 Mon Sep 17 00:00:00 2001 From: "iposva@google.com" Date: Fri, 31 Aug 2012 17:47:17 +0000 Subject: [PATCH 004/163] - Change "static final" to "static const" in the pkg/, language/, utils/ and lib/core/ directories. Review URL: https://chromiumcodereview.appspot.com//10919024 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@11703 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/logging.dart | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/logging/logging.dart b/pkgs/logging/logging.dart index e81ef71f..5b192d1d 100644 --- a/pkgs/logging/logging.dart +++ b/pkgs/logging/logging.dart @@ -261,34 +261,34 @@ class Level implements Comparable, Hashable { const Level(this.name, this.value); /** Special key to turn on logging for all levels ([value] = 0). */ - static final Level ALL = const Level('ALL', 0); + static const Level ALL = const Level('ALL', 0); /** Special key to turn off all logging ([value] = 2000). */ - static final Level OFF = const Level('OFF', 2000); + static const Level OFF = const Level('OFF', 2000); /** Key for highly detailed tracing ([value] = 300). */ - static final Level FINEST = const Level('FINEST', 300); + static const Level FINEST = const Level('FINEST', 300); /** Key for fairly detailed tracing ([value] = 400). */ - static final Level FINER = const Level('FINER', 400); + static const Level FINER = const Level('FINER', 400); /** Key for tracing information ([value] = 500). */ - static final Level FINE = const Level('FINE', 500); + static const Level FINE = const Level('FINE', 500); /** Key for static configuration messages ([value] = 700). */ - static final Level CONFIG = const Level('CONFIG', 700); + static const Level CONFIG = const Level('CONFIG', 700); /** Key for informational messages ([value] = 800). */ - static final Level INFO = const Level('INFO', 800); + static const Level INFO = const Level('INFO', 800); /** Key for potential problems ([value] = 900). */ - static final Level WARNING = const Level('WARNING', 900); + static const Level WARNING = const Level('WARNING', 900); /** Key for serious failures ([value] = 1000). */ - static final Level SEVERE = const Level('SEVERE', 1000); + static const Level SEVERE = const Level('SEVERE', 1000); /** Key for extra debugging loudness ([value] = 1200). */ - static final Level SHOUT = const Level('SHOUT', 1200); + static const Level SHOUT = const Level('SHOUT', 1200); bool operator ==(Level other) => other != null && value == other.value; bool operator <(Level other) => value < other.value; From ffa85ccf68288dbc78e8566dd1b2491c865ce661 Mon Sep 17 00:00:00 2001 From: "kasperl@google.com" Date: Fri, 7 Sep 2012 11:50:07 +0000 Subject: [PATCH 005/163] Get rid of a lot of () for getters. R=bak@google.com BUG= Review URL: https://chromiumcodereview.appspot.com//10919146 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@12017 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/logging.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/logging/logging.dart b/pkgs/logging/logging.dart index 5b192d1d..3d90ad7e 100644 --- a/pkgs/logging/logging.dart +++ b/pkgs/logging/logging.dart @@ -31,7 +31,7 @@ class Logger { final String name; /** The full name of this logger, which includes the parent's full name. */ - String get fullName() => + String get fullName => (parent == null || parent.name == '') ? name : '${parent.fullName}.$name'; /** Parent of this logger in the hierarchy of loggers. */ @@ -82,7 +82,7 @@ class Logger { * Effective level considering the levels established in this logger's parents * (when [hierarchicalLoggingEnabled] is true). */ - Level get level() { + Level get level { if (hierarchicalLoggingEnabled) { if (_level != null) return _level; if (parent != null) return parent.level; @@ -110,7 +110,7 @@ class Logger { * instance: * logger.on.record.add((record) { ... }); */ - LoggerEvents get on() => new LoggerEvents(this); + LoggerEvents get on => new LoggerEvents(this); /** Adds a handler to listen whenever a log record is added to this logger. */ void _addHandler(LoggerHandler handler) { @@ -201,7 +201,7 @@ class Logger { } /** Top-level root [Logger]. */ - static get root() => new Logger(''); + static get root => new Logger(''); /** All [Logger]s in the system. */ static Map _loggers; @@ -219,7 +219,7 @@ class LoggerEvents { LoggerEvents(this._logger); /** Event fired when a log record is added to a [Logger]. */ - LoggerHandlerList get record() => new LoggerHandlerList(_logger); + LoggerHandlerList get record => new LoggerHandlerList(_logger); } From 5c3d31ae0c47495ee8a52cce3d08d085a5c7d9b9 Mon Sep 17 00:00:00 2001 From: "rnystrom@google.com" Date: Thu, 13 Sep 2012 02:05:15 +0000 Subject: [PATCH 006/163] Move logging to the new package layout. Review URL: https://codereview.chromium.org//10908227 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@12293 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/{ => lib}/logging.dart | 0 pkgs/logging/test/logging_test.dart | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename pkgs/logging/{ => lib}/logging.dart (100%) diff --git a/pkgs/logging/logging.dart b/pkgs/logging/lib/logging.dart similarity index 100% rename from pkgs/logging/logging.dart rename to pkgs/logging/lib/logging.dart diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 66688100..e975dbd6 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -5,7 +5,8 @@ #library('logging_test'); -#import('../logging.dart'); +// TODO(rnystrom): Use "package:" import when test.dart supports it (#4968). +#import('../lib/logging.dart'); #import('../../../pkg/unittest/unittest.dart'); main() { From 282545806fea876d2095f5d90c69e9310cb325b7 Mon Sep 17 00:00:00 2001 From: "rnystrom@google.com" Date: Fri, 14 Sep 2012 18:22:24 +0000 Subject: [PATCH 007/163] Make unittest follow the new package layout. Review URL: https://codereview.chromium.org//10918240 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@12396 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index e975dbd6..1bed4a70 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -7,7 +7,7 @@ // TODO(rnystrom): Use "package:" import when test.dart supports it (#4968). #import('../lib/logging.dart'); -#import('../../../pkg/unittest/unittest.dart'); +#import('../../../pkg/unittest/lib/unittest.dart'); main() { test('level comparison is a valid comparator', () { From 1fa01de273db81d1dbea25b77e72085b038ec07f Mon Sep 17 00:00:00 2001 From: "rnystrom@google.com" Date: Fri, 14 Sep 2012 19:43:10 +0000 Subject: [PATCH 008/163] Revert "Make unittest follow the new package layout." This reverts commit 38f7d16f373832a7bf889192af7845cb602aec01. Review URL: https://codereview.chromium.org//10911318 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@12400 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 1bed4a70..e975dbd6 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -7,7 +7,7 @@ // TODO(rnystrom): Use "package:" import when test.dart supports it (#4968). #import('../lib/logging.dart'); -#import('../../../pkg/unittest/lib/unittest.dart'); +#import('../../../pkg/unittest/unittest.dart'); main() { test('level comparison is a valid comparator', () { From 9800b66c9c265a6b9a8eacb7cdb2de147466abc2 Mon Sep 17 00:00:00 2001 From: "rnystrom@google.com" Date: Fri, 14 Sep 2012 21:12:17 +0000 Subject: [PATCH 009/163] Update unittest to new package layout. Review URL: https://codereview.chromium.org//10917275 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@12404 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index e975dbd6..1bed4a70 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -7,7 +7,7 @@ // TODO(rnystrom): Use "package:" import when test.dart supports it (#4968). #import('../lib/logging.dart'); -#import('../../../pkg/unittest/unittest.dart'); +#import('../../../pkg/unittest/lib/unittest.dart'); main() { test('level comparison is a valid comparator', () { From 3e9e185640a34553be9ce3667ccf30f70e939c21 Mon Sep 17 00:00:00 2001 From: "efortuna@google.com" Date: Sat, 15 Sep 2012 01:21:41 +0000 Subject: [PATCH 010/163] revert 1204. Will investigate when I get a chance. TBR=rnystrom Review URL: https://codereview.chromium.org//10928216 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@12413 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 1bed4a70..e975dbd6 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -7,7 +7,7 @@ // TODO(rnystrom): Use "package:" import when test.dart supports it (#4968). #import('../lib/logging.dart'); -#import('../../../pkg/unittest/lib/unittest.dart'); +#import('../../../pkg/unittest/unittest.dart'); main() { test('level comparison is a valid comparator', () { From b7c30f8ce9cab0d4a30f221bdc91e113b60db698 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Tue, 25 Sep 2012 12:27:52 +0000 Subject: [PATCH 011/163] Change IllegalArgumentException to ArgumentError. Review URL: https://codereview.chromium.org//10989013 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@12841 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 3d90ad7e..6b7b13bb 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -52,7 +52,7 @@ class Logger { */ factory Logger(String name) { if (name.startsWith('.')) { - throw new IllegalArgumentException("name shouldn't start with a '.'"); + throw new ArgumentError("name shouldn't start with a '.'"); } if (_loggers == null) _loggers = {}; if (_loggers.containsKey(name)) return _loggers[name]; From 45957ca5981d882eb37533f228294302e3ef1728 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Thu, 27 Sep 2012 13:07:54 +0000 Subject: [PATCH 012/163] Stop using the Hashable interface. All objects have a hashCode method, so there is no need for a Hashable interface. The interface itself is retained for at least two weeks, to give time for code to remove uses of it. Review URL: https://codereview.chromium.org//10993059 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@12955 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 6b7b13bb..9a0ae91a 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -247,7 +247,7 @@ class LoggerHandlerList { * own level, make sure you use a value between those used in [Level.ALL] and * [Level.OFF]. */ -class Level implements Comparable, Hashable { +class Level implements Comparable { // TODO(sigmund): mark name/value as 'const' when the language supports it. final String name; From ae5ef400abd9823515f287f20757fd21736421bb Mon Sep 17 00:00:00 2001 From: "jmesserly@google.com" Date: Fri, 19 Oct 2012 23:43:48 +0000 Subject: [PATCH 013/163] fix warning in Logger (setter type must be "void" or "Dynamic") Review URL: https://codereview.chromium.org//11232024 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@13848 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 9a0ae91a..38cfa025 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -91,7 +91,7 @@ class Logger { } /** Override the level for this particular [Logger] and its children. */ - Level set level(value) { + set level(value) { if (hierarchicalLoggingEnabled && parent != null) { _level = value; } else { From cacbf8fb2e9e24ed1e0728b5df9a3fc201842f35 Mon Sep 17 00:00:00 2001 From: "floitsch@google.com" Date: Mon, 22 Oct 2012 12:41:04 +0000 Subject: [PATCH 014/163] Make hashCode a getter and not a method. Review URL: https://codereview.chromium.org//11191078 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@13866 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 38cfa025..8dc5ac12 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -296,7 +296,7 @@ class Level implements Comparable { bool operator >(Level other) => value > other.value; bool operator >=(Level other) => value >= other.value; int compareTo(Level other) => value - other.value; - int hashCode() => value; + int get hashCode => value; String toString() => name; } From d30215002a592fd66429b31d1a9d2b3bbff39b95 Mon Sep 17 00:00:00 2001 From: "scheglov@google.com" Date: Tue, 23 Oct 2012 13:20:50 +0000 Subject: [PATCH 015/163] Parts must start with 'part of' git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@13961 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- pkgs/logging/test/logging_test.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 8dc5ac12..b24ee5c0 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -7,7 +7,7 @@ * abstractions similar to those used in other languages, such as the Closure JS * Logger and java.util.logging.Logger. */ -#library('logging'); +library logging; /** * Whether to allow fine-grain logging and configuration of loggers in a diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index e975dbd6..8d274e1a 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -3,11 +3,11 @@ // BSD-style license that can be found in the LICENSE file. -#library('logging_test'); +library logging_test; // TODO(rnystrom): Use "package:" import when test.dart supports it (#4968). -#import('../lib/logging.dart'); -#import('../../../pkg/unittest/unittest.dart'); +import '../lib/logging.dart'; +import '../../../pkg/unittest/unittest.dart'; main() { test('level comparison is a valid comparator', () { From 16b42cd9141e527a5f8017eb595eaaf3a838cb83 Mon Sep 17 00:00:00 2001 From: "ahe@google.com" Date: Tue, 23 Oct 2012 14:24:04 +0000 Subject: [PATCH 016/163] Revert "Parts must start with 'part of'" and "Attempt to fix VM build" This reverts r13961 and r13963. Review URL: https://codereview.chromium.org//11233061 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@13967 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- pkgs/logging/test/logging_test.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index b24ee5c0..8dc5ac12 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -7,7 +7,7 @@ * abstractions similar to those used in other languages, such as the Closure JS * Logger and java.util.logging.Logger. */ -library logging; +#library('logging'); /** * Whether to allow fine-grain logging and configuration of loggers in a diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 8d274e1a..e975dbd6 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -3,11 +3,11 @@ // BSD-style license that can be found in the LICENSE file. -library logging_test; +#library('logging_test'); // TODO(rnystrom): Use "package:" import when test.dart supports it (#4968). -import '../lib/logging.dart'; -import '../../../pkg/unittest/unittest.dart'; +#import('../lib/logging.dart'); +#import('../../../pkg/unittest/unittest.dart'); main() { test('level comparison is a valid comparator', () { From 36f68377c95b6867e644e06442a0698153bec667 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Wed, 24 Oct 2012 12:36:10 +0000 Subject: [PATCH 017/163] Removed IllegalAccessException and UnsupportedOperationException. Both were converted to StateError. Review URL: https://codereview.chromium.org//11235054 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@14012 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 8dc5ac12..b423e203 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -96,7 +96,7 @@ class Logger { _level = value; } else { if (parent != null) { - throw new UnsupportedOperationException( + throw new UnsupportedError( 'Please set "hierarchicalLoggingEnabled" to true if you want to ' 'change the level on a non-root logger.'); } From dc434d9b5dbf3c75600927f2d243475aa951d90a Mon Sep 17 00:00:00 2001 From: "gram@google.com" Date: Fri, 26 Oct 2012 22:52:03 +0000 Subject: [PATCH 018/163] Modified unittest to use new argument syntax. Fix affected unit tests. Clean up unit tests that are using Expect instead of expect. Get rid of warnings about duplicated library names. Review URL: https://codereview.chromium.org//11275054 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@14158 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 48 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index e975dbd6..a3e1cd5d 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -12,21 +12,21 @@ main() { test('level comparison is a valid comparator', () { var level1 = const Level('NOT_REAL1', 253); - expect(level1 == level1); - expect(level1 <= level1); - expect(level1 >= level1); + expect(level1 == level1, isTrue); + expect(level1 <= level1, isTrue); + expect(level1 >= level1, isTrue); expect(level1 < level1, isFalse); expect(level1 > level1, isFalse); var level2 = const Level('NOT_REAL2', 455); - expect(level1 <= level2); - expect(level1 < level2); - expect(level2 >= level1); - expect(level2 > level1); + expect(level1 <= level2, isTrue); + expect(level1 < level2, isTrue); + expect(level2 >= level1, isTrue); + expect(level2 > level1, isTrue); var level3 = const Level('NOT_REAL3', 253); - expect(level1 !== level3); // different instances - expect(level1 == level3); // same value. + expect(level1 !== level3, isTrue); // different instances + expect(level1 == level3, isTrue); // same value. }); test('default levels are in order', () { @@ -37,7 +37,7 @@ main() { for (int i = 0; i < levels.length; i++) { for (int j = i + 1; j < levels.length; j++) { - expect(levels[i] < levels[j]); + expect(levels[i] < levels[j], isTrue); } } }); @@ -91,10 +91,10 @@ main() { Logger a = new Logger('a'); Logger b = new Logger('a.b'); Logger c = new Logger('a.c'); - expect(a == b.parent); - expect(a == c.parent); - expect(a.children['b'] == b); - expect(a.children['c'] == c); + expect(a == b.parent, isTrue); + expect(a == c.parent, isTrue); + expect(a.children['b'] == b, isTrue); + expect(a.children['c'] == c, isTrue); }); test('loggers are singletons', () { @@ -102,10 +102,10 @@ main() { Logger a2 = new Logger('a'); Logger b = new Logger('a.b'); Logger root = Logger.root; - expect(a1 === a2); - expect(a1 === b.parent); - expect(root === a1.parent); - expect(root === new Logger('')); + expect(a1 === a2, isTrue); + expect(a1 === b.parent, isTrue); + expect(root === a1.parent, isTrue); + expect(root === new Logger(''), isTrue); }); group('mutating levels', () { @@ -172,12 +172,12 @@ main() { c.level = Level.ALL; e.level = Level.OFF; - expect(root.isLoggable(Level.SHOUT)); - expect(root.isLoggable(Level.SEVERE)); - expect(!root.isLoggable(Level.WARNING)); - expect(c.isLoggable(Level.FINEST)); - expect(c.isLoggable(Level.FINE)); - expect(!e.isLoggable(Level.SHOUT)); + expect(root.isLoggable(Level.SHOUT), isTrue); + expect(root.isLoggable(Level.SEVERE), isTrue); + expect(root.isLoggable(Level.WARNING), isFalse); + expect(c.isLoggable(Level.FINEST), isTrue); + expect(c.isLoggable(Level.FINE), isTrue); + expect(!e.isLoggable(Level.SHOUT), isTrue); }); test('add/remove handlers - no hierarchy', () { From c044d283617d3cb5ced6503ab7cea589abf362c4 Mon Sep 17 00:00:00 2001 From: "gram@google.com" Date: Thu, 1 Nov 2012 23:09:47 +0000 Subject: [PATCH 019/163] Restructure pkg/unittest and pkg/webdriver to follow the pub conventions. This means all imports of unittest in our test code had to change to include 'lib' in the path. While doing that change I changed the library/imports to the new syntax in the affected files. Review URL: https://codereview.chromium.org//11301046 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@14443 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index a3e1cd5d..37518b12 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -3,11 +3,11 @@ // BSD-style license that can be found in the LICENSE file. -#library('logging_test'); +library logging_test; // TODO(rnystrom): Use "package:" import when test.dart supports it (#4968). -#import('../lib/logging.dart'); -#import('../../../pkg/unittest/unittest.dart'); +import '../lib/logging.dart'; +import '../../../pkg/unittest/lib/unittest.dart'; main() { test('level comparison is a valid comparator', () { From 18f259edc28bebb82cf258b08d80987be43d521b Mon Sep 17 00:00:00 2001 From: "gram@google.com" Date: Wed, 7 Nov 2012 18:52:40 +0000 Subject: [PATCH 020/163] Update library syntax in pkg files. Review URL: https://codereview.chromium.org//11362139 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@14646 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index b423e203..3713175d 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -7,7 +7,7 @@ * abstractions similar to those used in other languages, such as the Closure JS * Logger and java.util.logging.Logger. */ -#library('logging'); +library logging; /** * Whether to allow fine-grain logging and configuration of loggers in a From f0633a9d6d795278642669d82149c18f4e889f0c Mon Sep 17 00:00:00 2001 From: "floitsch@google.com" Date: Mon, 12 Nov 2012 17:19:58 +0000 Subject: [PATCH 021/163] a === b -> identical(a, b) Replace === null with == null. BUG=http://dartbug.com/6380 Review URL: https://codereview.chromium.org//11361190 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@14794 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 37518b12..fe1c4f0e 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -25,7 +25,7 @@ main() { expect(level2 > level1, isTrue); var level3 = const Level('NOT_REAL3', 253); - expect(level1 !== level3, isTrue); // different instances + expect(!identical(level1, level3), isTrue); // different instances expect(level1 == level3, isTrue); // same value. }); @@ -102,10 +102,10 @@ main() { Logger a2 = new Logger('a'); Logger b = new Logger('a.b'); Logger root = Logger.root; - expect(a1 === a2, isTrue); - expect(a1 === b.parent, isTrue); - expect(root === a1.parent, isTrue); - expect(root === new Logger(''), isTrue); + expect(identical(a1, a2), isTrue); + expect(identical(a1, b.parent), isTrue); + expect(identical(root, a1.parent), isTrue); + expect(identical(root, new Logger('')), isTrue); }); group('mutating levels', () { From 5d0f3d2b88a6535c6503bc361dd5f21d3e3042bb Mon Sep 17 00:00:00 2001 From: "dgrove@google.com" Date: Fri, 30 Nov 2012 21:16:01 +0000 Subject: [PATCH 022/163] Add authors and homepages to packages. Review URL: https://codereview.chromium.org//11418267 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@15601 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/pubspec.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 4a7e068c..33808980 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,4 +1,6 @@ name: logging +author: "Dart Team " +homepage: http://www.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 From 78a4ee10e601a45c7dc6f0673b9ab16e8682de8b Mon Sep 17 00:00:00 2001 From: "rnystrom@google.com" Date: Sat, 15 Dec 2012 01:05:35 +0000 Subject: [PATCH 023/163] Convert the small packages in pkg to use "package:". Review URL: https://codereview.chromium.org//11575043 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@16189 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index fe1c4f0e..e6809ea4 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -5,9 +5,8 @@ library logging_test; -// TODO(rnystrom): Use "package:" import when test.dart supports it (#4968). -import '../lib/logging.dart'; -import '../../../pkg/unittest/lib/unittest.dart'; +import 'package:logging/logging.dart'; +import 'package:/unittest/unittest.dart'; main() { test('level comparison is a valid comparator', () { From 32cf3de2b6674d9a7477dc96c9bb8fe7b7a2055c Mon Sep 17 00:00:00 2001 From: "rnystrom@google.com" Date: Sat, 15 Dec 2012 01:21:10 +0000 Subject: [PATCH 024/163] Fix URL. Review URL: https://codereview.chromium.org//11574051 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@16191 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index e6809ea4..6444e3aa 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -6,7 +6,7 @@ library logging_test; import 'package:logging/logging.dart'; -import 'package:/unittest/unittest.dart'; +import 'package:unittest/unittest.dart'; main() { test('level comparison is a valid comparator', () { From 5708cd2093b21e4858d39eabba89f9c54c636d52 Mon Sep 17 00:00:00 2001 From: "floitsch@google.com" Date: Thu, 24 Jan 2013 12:16:37 +0000 Subject: [PATCH 025/163] Rename Date to DateTime. BUG=http://dartbug.com/1424 Review URL: https://codereview.chromium.org//11770004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@17549 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 3713175d..5e0a2395 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -313,7 +313,7 @@ class LogRecord { final String loggerName; /** Time when this record was created. */ - final Date time; + final DateTime time; /** Unique sequence number greater than all log records created before it. */ final int sequenceNumber; @@ -329,6 +329,6 @@ class LogRecord { LogRecord( this.level, this.message, this.loggerName, [time, this.exception, this.exceptionText]) : - this.time = (time == null) ? new Date.now() : time, + this.time = (time == null) ? new DateTime.now() : time, this.sequenceNumber = LogRecord._nextNumber++; } From 2e0ef35cb1a59c3e126fd50fdb63d7706af75b0b Mon Sep 17 00:00:00 2001 From: "amouravski@google.com" Date: Tue, 12 Feb 2013 23:38:30 +0000 Subject: [PATCH 026/163] Added documentation links to all of the pkg packages hosted on api.dartlang.org. Review URL: https://codereview.chromium.org//12218119 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@18414 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 33808980..5c2c045c 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,6 +1,7 @@ name: logging author: "Dart Team " homepage: http://www.dartlang.org +documentation: http://api.dartlang.org/docs/pkg/logging.html description: > Provides APIs for debugging and error logging. This library introduces abstractions similar to those used in other languages, such as the Closure JS From 0f7b2738f64e312d79ad35946b29d903e6b6168e Mon Sep 17 00:00:00 2001 From: "dgrove@google.com" Date: Fri, 15 Feb 2013 01:27:10 +0000 Subject: [PATCH 027/163] Update documentation links to point to the correct URLs. Review URL: https://codereview.chromium.org//12252055 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@18552 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 5c2c045c..208667b4 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,7 +1,7 @@ name: logging author: "Dart Team " homepage: http://www.dartlang.org -documentation: http://api.dartlang.org/docs/pkg/logging.html +documentation: http://api.dartlang.org/docs/pkg/logging description: > Provides APIs for debugging and error logging. This library introduces abstractions similar to those used in other languages, such as the Closure JS From d57e1f4680fbced46456b5e76e7f4a679df95fb9 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Tue, 19 Feb 2013 07:52:24 +0000 Subject: [PATCH 028/163] Make Comparable generic. It's now allowed to write "class X implements Comparable" to make X comparable only to X's. The argument type of Comparable.compareTo is now T. Review URL: https://codereview.chromium.org//12255055 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@18655 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 5e0a2395..935b3aef 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -247,7 +247,7 @@ class LoggerHandlerList { * own level, make sure you use a value between those used in [Level.ALL] and * [Level.OFF]. */ -class Level implements Comparable { +class Level implements Comparable { // TODO(sigmund): mark name/value as 'const' when the language supports it. final String name; From cea2ad3aec7464f454598e651f0ff9e8c4ff9641 Mon Sep 17 00:00:00 2001 From: "kasperl@google.com" Date: Tue, 19 Feb 2013 08:06:03 +0000 Subject: [PATCH 029/163] Revert "Make Comparable generic." This reverts commit dd714db881a0ad63eaa1e5491e93dd8843eb5929. R=lrn@google.com BUG= Review URL: https://codereview.chromium.org//12298027 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@18657 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 935b3aef..5e0a2395 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -247,7 +247,7 @@ class LoggerHandlerList { * own level, make sure you use a value between those used in [Level.ALL] and * [Level.OFF]. */ -class Level implements Comparable { +class Level implements Comparable { // TODO(sigmund): mark name/value as 'const' when the language supports it. final String name; From 3b9b898bbee38e241846cbca6f51831fc996bb28 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Tue, 19 Feb 2013 10:29:44 +0000 Subject: [PATCH 030/163] Reapply "Make Comparable generic." Avoid concurrent modification in dart2js. Avoid crash in VM by not using self-referential type bound. Review URL: https://codereview.chromium.org//12288040 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@18667 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 5e0a2395..935b3aef 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -247,7 +247,7 @@ class LoggerHandlerList { * own level, make sure you use a value between those used in [Level.ALL] and * [Level.OFF]. */ -class Level implements Comparable { +class Level implements Comparable { // TODO(sigmund): mark name/value as 'const' when the language supports it. final String name; From f0c3cd5fd1f63d8ef7f0b00bb7d0601e7e0dcad1 Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Wed, 27 Feb 2013 23:43:01 +0000 Subject: [PATCH 031/163] make dartdoc and editor happy added type to Logger.level setter added type to Logger.root Review URL: https://codereview.chromium.org//12316126 Patch from Kevin Moore . git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@19186 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 935b3aef..89682fa5 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -91,7 +91,7 @@ class Logger { } /** Override the level for this particular [Logger] and its children. */ - set level(value) { + set level(Level value) { if (hierarchicalLoggingEnabled && parent != null) { _level = value; } else { @@ -201,7 +201,7 @@ class Logger { } /** Top-level root [Logger]. */ - static get root => new Logger(''); + static Logger get root => new Logger(''); /** All [Logger]s in the system. */ static Map _loggers; From 82a34dfe7933665d30b1c11b48171a68d2cc140d Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Thu, 28 Feb 2013 00:05:06 +0000 Subject: [PATCH 032/163] LoggerEvents get on -> Stream get onRecord Removed LoggerEvents, LoggerHandlerList, LoggerHandler BUG= Review URL: https://codereview.chromium.org//12334093 Patch from Kevin Moore . git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@19187 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 90 +++-- pkgs/logging/pubspec.yaml | 2 + .../logging/test/logging_deprecated_test.dart | 336 ++++++++++++++++++ pkgs/logging/test/logging_test.dart | 32 +- 4 files changed, 413 insertions(+), 47 deletions(-) create mode 100644 pkgs/logging/test/logging_deprecated_test.dart diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 89682fa5..a72a5280 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -9,6 +9,10 @@ */ library logging; +import 'dart:async'; + +import 'package:meta/meta.dart'; + /** * Whether to allow fine-grain logging and configuration of loggers in a * hierarchy. When false, all logging is merged in the root logger. @@ -43,8 +47,11 @@ class Logger { /** Children in the hierarchy of loggers, indexed by their simple names. */ Map children; - /** Handlers used to process log entries in this logger. */ - List _handlers; + /** Controller used to notify when log entries are added to this logger. */ + StreamController _controller; + + // TODO(sigmund): remove together with the deprecated [on] API. + Map _deprecatedSubscriptions; /** * Singleton constructor. Calling `new Logger(name)` will return the same @@ -109,38 +116,27 @@ class Logger { * by adding a [LoggerHandler] to an event from the event manager, for * instance: * logger.on.record.add((record) { ... }); + * + * This API is Deprecated. Use [onRecord] instead. */ + @deprecated LoggerEvents get on => new LoggerEvents(this); - /** Adds a handler to listen whenever a log record is added to this logger. */ - void _addHandler(LoggerHandler handler) { - if (hierarchicalLoggingEnabled || parent == null) { - if (_handlers == null) { - _handlers = new List(); - } - _handlers.add(handler); - } else { - root._addHandler(handler); - } - } - - /** Remove a previously added handler. */ - void _removeHandler(LoggerHandler handler) { - if (hierarchicalLoggingEnabled || parent == null) { - if (_handlers == null) return; - int index = _handlers.indexOf(handler); - if (index != -1) _handlers.removeRange(index, 1); - } else { - root._removeHandler(handler); - } - } + /** + * Returns an stream of messages added to this [Logger]. You can listen for + * messages using the standard stream APIs, for instance: + * logger.onRecord.listen((record) { ... }); + */ + Stream get onRecord => _getStream(); - /** Removes all handlers previously added to this logger. */ - void _clearHandlers() { + void clearListeners() { if (hierarchicalLoggingEnabled || parent == null) { - _handlers = null; + if (_controller != null) { + _controller.close(); + _controller = null; + } } else { - root._clearHandlers(); + root.clearListeners(); } } @@ -194,9 +190,41 @@ class Logger { /** Log message at level [Level.SHOUT]. */ void shout(String message) => log(Level.SHOUT, message); + Stream _getStream() { + if (hierarchicalLoggingEnabled || parent == null) { + if (_controller == null) { + _controller = new StreamController.broadcast(); + } + return _controller.stream; + } else { + return root._getStream(); + } + } + + /** Adds a handler to listen whenever a log record is added to this logger. */ + void _addHandler(LoggerHandler handler) { + if (_deprecatedSubscriptions == null) { + _deprecatedSubscriptions = new Map(); + } + + _deprecatedSubscriptions[handler] = onRecord.listen(handler); + } + + void _removeHandler(LoggerHandler handler) { + if (_deprecatedSubscriptions != null) { + var sub = _deprecatedSubscriptions.remove(handler); + if (sub != null) { + sub.cancel(); + } + if (_deprecatedSubscriptions.isEmpty) { + _deprecatedSubscriptions = null; + } + } + } + void _publish(LogRecord record) { - if (_handlers != null) { - _handlers.forEach((h) => h(record)); + if (_controller != null) { + _controller.add(record); } } @@ -231,7 +259,7 @@ class LoggerHandlerList { void add(LoggerHandler handler) => _logger._addHandler(handler); void remove(LoggerHandler handler) => _logger._removeHandler(handler); - void clear() => _logger._clearHandlers(); + void clear() => _logger.clearListeners(); } diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 208667b4..6e6a540e 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -8,5 +8,7 @@ description: > Logger and java.util.logging.Logger. dependencies: + meta: + sdk: meta unittest: sdk: unittest diff --git a/pkgs/logging/test/logging_deprecated_test.dart b/pkgs/logging/test/logging_deprecated_test.dart new file mode 100644 index 00000000..6444e3aa --- /dev/null +++ b/pkgs/logging/test/logging_deprecated_test.dart @@ -0,0 +1,336 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// 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 'package:logging/logging.dart'; +import 'package:unittest/unittest.dart'; + +main() { + test('level comparison is a valid comparator', () { + var level1 = const Level('NOT_REAL1', 253); + expect(level1 == level1, isTrue); + expect(level1 <= level1, isTrue); + expect(level1 >= level1, isTrue); + expect(level1 < level1, isFalse); + expect(level1 > level1, isFalse); + + var level2 = const Level('NOT_REAL2', 455); + expect(level1 <= level2, isTrue); + expect(level1 < level2, isTrue); + expect(level2 >= level1, isTrue); + expect(level2 > level1, isTrue); + + var level3 = const Level('NOT_REAL3', 253); + expect(!identical(level1, level3), isTrue); // different instances + expect(level1 == level3, isTrue); // same value. + }); + + 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 + ]; + + for (int i = 0; i < levels.length; i++) { + for (int j = i + 1; j < levels.length; j++) { + expect(levels[i] < levels[j], isTrue); + } + } + }); + + 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, + ]; + final sorted = const [ + Level.ALL, Level.FINEST, Level.FINER, Level.FINE, Level.CONFIG, + Level.INFO, Level.WARNING, Level.SEVERE, Level.SHOUT, Level.OFF + ]; + expect(unsorted, isNot(orderedEquals(sorted))); + + unsorted.sort((a, b) => a.compareTo(b)); + expect(unsorted, orderedEquals(sorted)); + }); + + test('levels are hashable', () { + var map = new Map(); + map[Level.INFO] = 'info'; + map[Level.SHOUT] = 'shout'; + expect(map[Level.INFO], equals('info')); + expect(map[Level.SHOUT], equals('shout')); + }); + + test('logger name cannot start with a "." ', () { + expect(() => new Logger('.c'), throws); + }); + + test('logger naming is hierarchical', () { + Logger c = new Logger('a.b.c'); + expect(c.name, equals('c')); + expect(c.parent.name, equals('b')); + expect(c.parent.parent.name, equals('a')); + expect(c.parent.parent.parent.name, equals('')); + expect(c.parent.parent.parent.parent, isNull); + }); + + test('logger full name', () { + Logger c = new Logger('a.b.c'); + expect(c.fullName, equals('a.b.c')); + expect(c.parent.fullName, equals('a.b')); + expect(c.parent.parent.fullName, equals('a')); + expect(c.parent.parent.parent.fullName, equals('')); + expect(c.parent.parent.parent.parent, isNull); + }); + + test('logger parent-child links are correct', () { + Logger a = new Logger('a'); + Logger b = new Logger('a.b'); + Logger c = new Logger('a.c'); + expect(a == b.parent, isTrue); + expect(a == c.parent, isTrue); + expect(a.children['b'] == b, isTrue); + expect(a.children['c'] == c, isTrue); + }); + + test('loggers are singletons', () { + Logger a1 = new Logger('a'); + Logger a2 = new Logger('a'); + Logger b = new Logger('a.b'); + Logger root = Logger.root; + expect(identical(a1, a2), isTrue); + expect(identical(a1, b.parent), isTrue); + expect(identical(root, a1.parent), isTrue); + expect(identical(root, new Logger('')), isTrue); + }); + + group('mutating levels', () { + Logger root = Logger.root; + Logger a = new Logger('a'); + Logger b = new Logger('a.b'); + Logger c = new Logger('a.b.c'); + Logger d = new Logger('a.b.c.d'); + Logger e = new Logger('a.b.c.d.e'); + + setUp(() { + hierarchicalLoggingEnabled = true; + root.level = Level.INFO; + a.level = null; + b.level = null; + c.level = null; + d.level = null; + e.level = null; + root.on.record.clear(); + a.on.record.clear(); + b.on.record.clear(); + c.on.record.clear(); + d.on.record.clear(); + e.on.record.clear(); + hierarchicalLoggingEnabled = false; + root.level = Level.INFO; + }); + + test('cannot set level if hierarchy is disabled', () { + expect(() {a.level = Level.FINE;}, throws); + }); + + test('loggers effective level - no hierarchy', () { + expect(root.level, equals(Level.INFO)); + expect(a.level, equals(Level.INFO)); + expect(b.level, equals(Level.INFO)); + + root.level = Level.SHOUT; + + expect(root.level, equals(Level.SHOUT)); + expect(a.level, equals(Level.SHOUT)); + expect(b.level, equals(Level.SHOUT)); + }); + + test('loggers effective level - with hierarchy', () { + hierarchicalLoggingEnabled = true; + expect(root.level, equals(Level.INFO)); + expect(a.level, equals(Level.INFO)); + expect(b.level, equals(Level.INFO)); + expect(c.level, equals(Level.INFO)); + + root.level = Level.SHOUT; + b.level = Level.FINE; + + expect(root.level, equals(Level.SHOUT)); + expect(a.level, equals(Level.SHOUT)); + expect(b.level, equals(Level.FINE)); + expect(c.level, equals(Level.FINE)); + }); + + test('isLoggable is appropriate', () { + hierarchicalLoggingEnabled = true; + root.level = Level.SEVERE; + c.level = Level.ALL; + e.level = Level.OFF; + + expect(root.isLoggable(Level.SHOUT), isTrue); + expect(root.isLoggable(Level.SEVERE), isTrue); + expect(root.isLoggable(Level.WARNING), isFalse); + expect(c.isLoggable(Level.FINEST), isTrue); + expect(c.isLoggable(Level.FINE), isTrue); + expect(!e.isLoggable(Level.SHOUT), isTrue); + }); + + test('add/remove handlers - no hierarchy', () { + int calls = 0; + var handler = (_) { calls++; }; + c.on.record.add(handler); + root.info("foo"); + root.info("foo"); + expect(calls, equals(2)); + c.on.record.remove(handler); + root.info("foo"); + expect(calls, equals(2)); + }); + + test('add/remove handlers - with hierarchy', () { + hierarchicalLoggingEnabled = true; + int calls = 0; + var handler = (_) { calls++; }; + c.on.record.add(handler); + root.info("foo"); + root.info("foo"); + expect(calls, equals(0)); + }); + + test('logging methods store appropriate level', () { + root.level = Level.ALL; + var rootMessages = []; + root.on.record.add((record) { + rootMessages.add('${record.level}: ${record.message}'); + }); + + root.finest('1'); + root.finer('2'); + root.fine('3'); + root.config('4'); + root.info('5'); + root.warning('6'); + root.severe('7'); + root.shout('8'); + + expect(rootMessages, equals([ + 'FINEST: 1', + 'FINER: 2', + 'FINE: 3', + 'CONFIG: 4', + 'INFO: 5', + 'WARNING: 6', + 'SEVERE: 7', + 'SHOUT: 8'])); + }); + + test('message logging - no hierarchy', () { + root.level = Level.WARNING; + var rootMessages = []; + var aMessages = []; + var cMessages = []; + c.on.record.add((record) { + cMessages.add('${record.level}: ${record.message}'); + }); + a.on.record.add((record) { + aMessages.add('${record.level}: ${record.message}'); + }); + root.on.record.add((record) { + rootMessages.add('${record.level}: ${record.message}'); + }); + + root.info('1'); + root.fine('2'); + root.shout('3'); + + b.info('4'); + b.severe('5'); + b.warning('6'); + b.fine('7'); + + c.fine('8'); + c.warning('9'); + 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'])); + + // no hierarchy means we all hear the same thing. + expect(aMessages, equals(rootMessages)); + expect(cMessages, equals(rootMessages)); + }); + + test('message logging - with hierarchy', () { + hierarchicalLoggingEnabled = true; + + b.level = Level.WARNING; + + var rootMessages = []; + var aMessages = []; + var cMessages = []; + c.on.record.add((record) { + cMessages.add('${record.level}: ${record.message}'); + }); + a.on.record.add((record) { + aMessages.add('${record.level}: ${record.message}'); + }); + root.on.record.add((record) { + rootMessages.add('${record.level}: ${record.message}'); + }); + + root.info('1'); + root.fine('2'); + root.shout('3'); + + b.info('4'); + b.severe('5'); + b.warning('6'); + b.fine('7'); + + c.fine('8'); + c.warning('9'); + 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'])); + + 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'])); + + expect(cMessages, equals([ + // 1 - 7 are lower in the hierarchy + // 'FINE: 8' is not loggable + 'WARNING: 9', + 'SHOUT: 10'])); + }); + }); +} diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 6444e3aa..1af342f5 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -123,12 +123,12 @@ main() { c.level = null; d.level = null; e.level = null; - root.on.record.clear(); - a.on.record.clear(); - b.on.record.clear(); - c.on.record.clear(); - d.on.record.clear(); - e.on.record.clear(); + root.clearListeners(); + a.clearListeners(); + b.clearListeners(); + c.clearListeners(); + d.clearListeners(); + e.clearListeners(); hierarchicalLoggingEnabled = false; root.level = Level.INFO; }); @@ -182,11 +182,11 @@ main() { test('add/remove handlers - no hierarchy', () { int calls = 0; var handler = (_) { calls++; }; - c.on.record.add(handler); + final sub = c.onRecord.listen(handler); root.info("foo"); root.info("foo"); expect(calls, equals(2)); - c.on.record.remove(handler); + sub.cancel(); root.info("foo"); expect(calls, equals(2)); }); @@ -195,7 +195,7 @@ main() { hierarchicalLoggingEnabled = true; int calls = 0; var handler = (_) { calls++; }; - c.on.record.add(handler); + c.onRecord.listen(handler); root.info("foo"); root.info("foo"); expect(calls, equals(0)); @@ -204,7 +204,7 @@ main() { test('logging methods store appropriate level', () { root.level = Level.ALL; var rootMessages = []; - root.on.record.add((record) { + root.onRecord.listen((record) { rootMessages.add('${record.level}: ${record.message}'); }); @@ -233,13 +233,13 @@ main() { var rootMessages = []; var aMessages = []; var cMessages = []; - c.on.record.add((record) { + c.onRecord.listen((record) { cMessages.add('${record.level}: ${record.message}'); }); - a.on.record.add((record) { + a.onRecord.listen((record) { aMessages.add('${record.level}: ${record.message}'); }); - root.on.record.add((record) { + root.onRecord.listen((record) { rootMessages.add('${record.level}: ${record.message}'); }); @@ -281,13 +281,13 @@ main() { var rootMessages = []; var aMessages = []; var cMessages = []; - c.on.record.add((record) { + c.onRecord.listen((record) { cMessages.add('${record.level}: ${record.message}'); }); - a.on.record.add((record) { + a.onRecord.listen((record) { aMessages.add('${record.level}: ${record.message}'); }); - root.on.record.add((record) { + root.onRecord.listen((record) { rootMessages.add('${record.level}: ${record.message}'); }); From 62985e0744e07fa0ab415f44c63862c43fa52152 Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Fri, 1 Mar 2013 00:32:14 +0000 Subject: [PATCH 033/163] Don't use package: imports in logging until dartdoc/mirros support them. Review URL: https://codereview.chromium.org//12380042 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@19270 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- pkgs/logging/test/logging_deprecated_test.dart | 2 +- pkgs/logging/test/logging_test.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index a72a5280..1bf617c5 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -11,7 +11,7 @@ library logging; import 'dart:async'; -import 'package:meta/meta.dart'; +import '../../meta/lib/meta.dart'; /** * Whether to allow fine-grain logging and configuration of loggers in a diff --git a/pkgs/logging/test/logging_deprecated_test.dart b/pkgs/logging/test/logging_deprecated_test.dart index 6444e3aa..10ab6168 100644 --- a/pkgs/logging/test/logging_deprecated_test.dart +++ b/pkgs/logging/test/logging_deprecated_test.dart @@ -5,7 +5,7 @@ library logging_test; -import 'package:logging/logging.dart'; +import '../../../pkg/logging/lib/logging.dart'; import 'package:unittest/unittest.dart'; main() { diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 1af342f5..5102c423 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -5,7 +5,7 @@ library logging_test; -import 'package:logging/logging.dart'; +import '../../../pkg/logging/lib/logging.dart'; import 'package:unittest/unittest.dart'; main() { From fbfbc94023a50d34e310cefc9d4fa1908f253b54 Mon Sep 17 00:00:00 2001 From: "kevmoo@j832.com" Date: Wed, 20 Mar 2013 19:41:10 +0000 Subject: [PATCH 034/163] Moved pkg pubspecs to use dev_dependencies where appropriate BUG=https://code.google.com/p/dart/issues/detail?id=9309 Review URL: https://codereview.chromium.org//12962003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@20285 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/pubspec.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 6e6a540e..16c44285 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -8,7 +8,6 @@ description: > Logger and java.util.logging.Logger. dependencies: - meta: - sdk: meta - unittest: - sdk: unittest + meta: any +dev_dependencies: + unittest: any From f80f4b950561510caacf335c66980a5f7a3e69a4 Mon Sep 17 00:00:00 2001 From: "dgrove@google.com" Date: Mon, 25 Mar 2013 20:03:01 +0000 Subject: [PATCH 035/163] Make path to meta go through pkg/ , so that it's rewritten properly. Review URL: https://codereview.chromium.org//12512008 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@20479 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 1bf617c5..d12d22b4 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -11,7 +11,9 @@ library logging; import 'dart:async'; -import '../../meta/lib/meta.dart'; +// Please leave the pkg in place here, as the publish_pkg.py script +// needs it to rewrite imports correctly. +import '../../../pkg/meta/lib/meta.dart'; /** * Whether to allow fine-grain logging and configuration of loggers in a From 27d5ad860f5ed08582041f33d9b18d70a27768c0 Mon Sep 17 00:00:00 2001 From: "kevmoo@j832.com" Date: Wed, 27 Mar 2013 20:36:17 +0000 Subject: [PATCH 036/163] pkg/logging: removed deprecated 'on' API Review URL: https://codereview.chromium.org//12600033 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@20574 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 63 ---- pkgs/logging/pubspec.yaml | 10 +- .../logging/test/logging_deprecated_test.dart | 336 ------------------ 3 files changed, 2 insertions(+), 407 deletions(-) delete mode 100644 pkgs/logging/test/logging_deprecated_test.dart diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index d12d22b4..d2610b1c 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -11,10 +11,6 @@ library logging; import 'dart:async'; -// Please leave the pkg in place here, as the publish_pkg.py script -// needs it to rewrite imports correctly. -import '../../../pkg/meta/lib/meta.dart'; - /** * Whether to allow fine-grain logging and configuration of loggers in a * hierarchy. When false, all logging is merged in the root logger. @@ -52,9 +48,6 @@ class Logger { /** Controller used to notify when log entries are added to this logger. */ StreamController _controller; - // TODO(sigmund): remove together with the deprecated [on] API. - Map _deprecatedSubscriptions; - /** * Singleton constructor. Calling `new Logger(name)` will return the same * actual instance whenever it is called with the same string name. @@ -113,17 +106,6 @@ class Logger { } } - /** - * Returns an event manager for this [Logger]. You can listen for log messages - * by adding a [LoggerHandler] to an event from the event manager, for - * instance: - * logger.on.record.add((record) { ... }); - * - * This API is Deprecated. Use [onRecord] instead. - */ - @deprecated - LoggerEvents get on => new LoggerEvents(this); - /** * Returns an stream of messages added to this [Logger]. You can listen for * messages using the standard stream APIs, for instance: @@ -203,27 +185,6 @@ class Logger { } } - /** Adds a handler to listen whenever a log record is added to this logger. */ - void _addHandler(LoggerHandler handler) { - if (_deprecatedSubscriptions == null) { - _deprecatedSubscriptions = new Map(); - } - - _deprecatedSubscriptions[handler] = onRecord.listen(handler); - } - - void _removeHandler(LoggerHandler handler) { - if (_deprecatedSubscriptions != null) { - var sub = _deprecatedSubscriptions.remove(handler); - if (sub != null) { - sub.cancel(); - } - if (_deprecatedSubscriptions.isEmpty) { - _deprecatedSubscriptions = null; - } - } - } - void _publish(LogRecord record) { if (_controller != null) { _controller.add(record); @@ -241,30 +202,6 @@ class Logger { /** Handler callback to process log entries as they are added to a [Logger]. */ typedef void LoggerHandler(LogRecord); - -/** Event manager for a [Logger] (holds events that a [Logger] can fire). */ -class LoggerEvents { - final Logger _logger; - - LoggerEvents(this._logger); - - /** Event fired when a log record is added to a [Logger]. */ - LoggerHandlerList get record => new LoggerHandlerList(_logger); -} - - -/** List of handlers that will be called on a logger event. */ -class LoggerHandlerList { - Logger _logger; - - LoggerHandlerList(this._logger); - - void add(LoggerHandler handler) => _logger._addHandler(handler); - void remove(LoggerHandler handler) => _logger._removeHandler(handler); - void clear() => _logger.clearListeners(); -} - - /** * [Level]s to control logging output. Logging can be enabled to include all * levels above certain [Level]. [Level]s are ordered using an integer diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 16c44285..37ed46e6 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,13 +1,7 @@ name: logging -author: "Dart Team " +author: Dart Team +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 -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. - -dependencies: - meta: any dev_dependencies: unittest: any diff --git a/pkgs/logging/test/logging_deprecated_test.dart b/pkgs/logging/test/logging_deprecated_test.dart deleted file mode 100644 index 10ab6168..00000000 --- a/pkgs/logging/test/logging_deprecated_test.dart +++ /dev/null @@ -1,336 +0,0 @@ -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file -// 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 '../../../pkg/logging/lib/logging.dart'; -import 'package:unittest/unittest.dart'; - -main() { - test('level comparison is a valid comparator', () { - var level1 = const Level('NOT_REAL1', 253); - expect(level1 == level1, isTrue); - expect(level1 <= level1, isTrue); - expect(level1 >= level1, isTrue); - expect(level1 < level1, isFalse); - expect(level1 > level1, isFalse); - - var level2 = const Level('NOT_REAL2', 455); - expect(level1 <= level2, isTrue); - expect(level1 < level2, isTrue); - expect(level2 >= level1, isTrue); - expect(level2 > level1, isTrue); - - var level3 = const Level('NOT_REAL3', 253); - expect(!identical(level1, level3), isTrue); // different instances - expect(level1 == level3, isTrue); // same value. - }); - - 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 - ]; - - for (int i = 0; i < levels.length; i++) { - for (int j = i + 1; j < levels.length; j++) { - expect(levels[i] < levels[j], isTrue); - } - } - }); - - 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, - ]; - final sorted = const [ - Level.ALL, Level.FINEST, Level.FINER, Level.FINE, Level.CONFIG, - Level.INFO, Level.WARNING, Level.SEVERE, Level.SHOUT, Level.OFF - ]; - expect(unsorted, isNot(orderedEquals(sorted))); - - unsorted.sort((a, b) => a.compareTo(b)); - expect(unsorted, orderedEquals(sorted)); - }); - - test('levels are hashable', () { - var map = new Map(); - map[Level.INFO] = 'info'; - map[Level.SHOUT] = 'shout'; - expect(map[Level.INFO], equals('info')); - expect(map[Level.SHOUT], equals('shout')); - }); - - test('logger name cannot start with a "." ', () { - expect(() => new Logger('.c'), throws); - }); - - test('logger naming is hierarchical', () { - Logger c = new Logger('a.b.c'); - expect(c.name, equals('c')); - expect(c.parent.name, equals('b')); - expect(c.parent.parent.name, equals('a')); - expect(c.parent.parent.parent.name, equals('')); - expect(c.parent.parent.parent.parent, isNull); - }); - - test('logger full name', () { - Logger c = new Logger('a.b.c'); - expect(c.fullName, equals('a.b.c')); - expect(c.parent.fullName, equals('a.b')); - expect(c.parent.parent.fullName, equals('a')); - expect(c.parent.parent.parent.fullName, equals('')); - expect(c.parent.parent.parent.parent, isNull); - }); - - test('logger parent-child links are correct', () { - Logger a = new Logger('a'); - Logger b = new Logger('a.b'); - Logger c = new Logger('a.c'); - expect(a == b.parent, isTrue); - expect(a == c.parent, isTrue); - expect(a.children['b'] == b, isTrue); - expect(a.children['c'] == c, isTrue); - }); - - test('loggers are singletons', () { - Logger a1 = new Logger('a'); - Logger a2 = new Logger('a'); - Logger b = new Logger('a.b'); - Logger root = Logger.root; - expect(identical(a1, a2), isTrue); - expect(identical(a1, b.parent), isTrue); - expect(identical(root, a1.parent), isTrue); - expect(identical(root, new Logger('')), isTrue); - }); - - group('mutating levels', () { - Logger root = Logger.root; - Logger a = new Logger('a'); - Logger b = new Logger('a.b'); - Logger c = new Logger('a.b.c'); - Logger d = new Logger('a.b.c.d'); - Logger e = new Logger('a.b.c.d.e'); - - setUp(() { - hierarchicalLoggingEnabled = true; - root.level = Level.INFO; - a.level = null; - b.level = null; - c.level = null; - d.level = null; - e.level = null; - root.on.record.clear(); - a.on.record.clear(); - b.on.record.clear(); - c.on.record.clear(); - d.on.record.clear(); - e.on.record.clear(); - hierarchicalLoggingEnabled = false; - root.level = Level.INFO; - }); - - test('cannot set level if hierarchy is disabled', () { - expect(() {a.level = Level.FINE;}, throws); - }); - - test('loggers effective level - no hierarchy', () { - expect(root.level, equals(Level.INFO)); - expect(a.level, equals(Level.INFO)); - expect(b.level, equals(Level.INFO)); - - root.level = Level.SHOUT; - - expect(root.level, equals(Level.SHOUT)); - expect(a.level, equals(Level.SHOUT)); - expect(b.level, equals(Level.SHOUT)); - }); - - test('loggers effective level - with hierarchy', () { - hierarchicalLoggingEnabled = true; - expect(root.level, equals(Level.INFO)); - expect(a.level, equals(Level.INFO)); - expect(b.level, equals(Level.INFO)); - expect(c.level, equals(Level.INFO)); - - root.level = Level.SHOUT; - b.level = Level.FINE; - - expect(root.level, equals(Level.SHOUT)); - expect(a.level, equals(Level.SHOUT)); - expect(b.level, equals(Level.FINE)); - expect(c.level, equals(Level.FINE)); - }); - - test('isLoggable is appropriate', () { - hierarchicalLoggingEnabled = true; - root.level = Level.SEVERE; - c.level = Level.ALL; - e.level = Level.OFF; - - expect(root.isLoggable(Level.SHOUT), isTrue); - expect(root.isLoggable(Level.SEVERE), isTrue); - expect(root.isLoggable(Level.WARNING), isFalse); - expect(c.isLoggable(Level.FINEST), isTrue); - expect(c.isLoggable(Level.FINE), isTrue); - expect(!e.isLoggable(Level.SHOUT), isTrue); - }); - - test('add/remove handlers - no hierarchy', () { - int calls = 0; - var handler = (_) { calls++; }; - c.on.record.add(handler); - root.info("foo"); - root.info("foo"); - expect(calls, equals(2)); - c.on.record.remove(handler); - root.info("foo"); - expect(calls, equals(2)); - }); - - test('add/remove handlers - with hierarchy', () { - hierarchicalLoggingEnabled = true; - int calls = 0; - var handler = (_) { calls++; }; - c.on.record.add(handler); - root.info("foo"); - root.info("foo"); - expect(calls, equals(0)); - }); - - test('logging methods store appropriate level', () { - root.level = Level.ALL; - var rootMessages = []; - root.on.record.add((record) { - rootMessages.add('${record.level}: ${record.message}'); - }); - - root.finest('1'); - root.finer('2'); - root.fine('3'); - root.config('4'); - root.info('5'); - root.warning('6'); - root.severe('7'); - root.shout('8'); - - expect(rootMessages, equals([ - 'FINEST: 1', - 'FINER: 2', - 'FINE: 3', - 'CONFIG: 4', - 'INFO: 5', - 'WARNING: 6', - 'SEVERE: 7', - 'SHOUT: 8'])); - }); - - test('message logging - no hierarchy', () { - root.level = Level.WARNING; - var rootMessages = []; - var aMessages = []; - var cMessages = []; - c.on.record.add((record) { - cMessages.add('${record.level}: ${record.message}'); - }); - a.on.record.add((record) { - aMessages.add('${record.level}: ${record.message}'); - }); - root.on.record.add((record) { - rootMessages.add('${record.level}: ${record.message}'); - }); - - root.info('1'); - root.fine('2'); - root.shout('3'); - - b.info('4'); - b.severe('5'); - b.warning('6'); - b.fine('7'); - - c.fine('8'); - c.warning('9'); - 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'])); - - // no hierarchy means we all hear the same thing. - expect(aMessages, equals(rootMessages)); - expect(cMessages, equals(rootMessages)); - }); - - test('message logging - with hierarchy', () { - hierarchicalLoggingEnabled = true; - - b.level = Level.WARNING; - - var rootMessages = []; - var aMessages = []; - var cMessages = []; - c.on.record.add((record) { - cMessages.add('${record.level}: ${record.message}'); - }); - a.on.record.add((record) { - aMessages.add('${record.level}: ${record.message}'); - }); - root.on.record.add((record) { - rootMessages.add('${record.level}: ${record.message}'); - }); - - root.info('1'); - root.fine('2'); - root.shout('3'); - - b.info('4'); - b.severe('5'); - b.warning('6'); - b.fine('7'); - - c.fine('8'); - c.warning('9'); - 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'])); - - 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'])); - - expect(cMessages, equals([ - // 1 - 7 are lower in the hierarchy - // 'FINE: 8' is not loggable - 'WARNING: 9', - 'SHOUT: 10'])); - }); - }); -} From f52ed0a84e917d07dc5fcea6dc634f9d3a6447aa Mon Sep 17 00:00:00 2001 From: "nweiz@google.com" Date: Thu, 28 Mar 2013 20:27:28 +0000 Subject: [PATCH 037/163] Switch pkg packages, pub, and dartdoc to use package: imports. This also changes the SDK layout by replacing the "pkg" directory, which contained the full source of all the packages needed by pub and dartdoc, with a "packages" directory that contains only their lib directories. This directory is used as the package root for pub and dartdoc when run from the SDK. BUG=6745 Review URL: https://codereview.chromium.org//12782016 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@20640 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/test/logging_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 5102c423..1af342f5 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -5,7 +5,7 @@ library logging_test; -import '../../../pkg/logging/lib/logging.dart'; +import 'package:logging/logging.dart'; import 'package:unittest/unittest.dart'; main() { From d06a26d99a02e56da9a8ed2b57017debe936af77 Mon Sep 17 00:00:00 2001 From: "floitsch@google.com" Date: Mon, 15 Apr 2013 19:08:17 +0000 Subject: [PATCH 038/163] Remove StreamController.broadcast. Review URL: https://codereview.chromium.org//14136004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@21499 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index d2610b1c..222ff1e4 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -48,6 +48,9 @@ class Logger { /** Controller used to notify when log entries are added to this logger. */ StreamController _controller; + /** The broadcast stream associated with the controller. */ + Stream _stream; + /** * Singleton constructor. Calling `new Logger(name)` will return the same * actual instance whenever it is called with the same string name. @@ -177,9 +180,10 @@ class Logger { Stream _getStream() { if (hierarchicalLoggingEnabled || parent == null) { if (_controller == null) { - _controller = new StreamController.broadcast(); + _controller = new StreamController(); + _stream = _controller.stream.asBroadcastStream(); } - return _controller.stream; + return _stream; } else { return root._getStream(); } From 9fafd486db96f015f69f7f43c0b616513fb3bc99 Mon Sep 17 00:00:00 2001 From: "sethladd@google.com" Date: Fri, 19 Apr 2013 20:51:10 +0000 Subject: [PATCH 039/163] add installation instructions to pkg packages BUG= Review URL: https://codereview.chromium.org//14188048 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@21770 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 222ff1e4..94bf5f3d 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -6,6 +6,22 @@ * 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. + * + * ## Installing ## + * + * Use [pub][] to install this package. Add the following to your `pubspec.yaml` + * file. + * + * dependencies: + * logging: any + * + * Then run `pub install`. + * + * For more information, see the + * [logging package on pub.dartlang.org][pkg]. + * + * [pub]: http://pub.dartlang.org + * [pkg]: http://pub.dartlang.org/packages/logging */ library logging; From 685c91b268c5ae75bea749d79fd4b89af501fd35 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Fri, 31 May 2013 06:07:39 +0000 Subject: [PATCH 040/163] Make new StreamController be async by default. Change all instances, except some tests, to be sync still. Rename Multiplex to Broadcast everywhere. R=floitsch@google.com Review URL: https://codereview.chromium.org//16125005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@23453 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 94bf5f3d..b29f076c 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -196,7 +196,7 @@ class Logger { Stream _getStream() { if (hierarchicalLoggingEnabled || parent == null) { if (_controller == null) { - _controller = new StreamController(); + _controller = new StreamController(sync: true); _stream = _controller.stream.asBroadcastStream(); } return _stream; From 4ed8407f7be41259913c3a63103fe5f48440979d Mon Sep 17 00:00:00 2001 From: "sigmund@google.com" Date: Thu, 20 Jun 2013 19:43:00 +0000 Subject: [PATCH 041/163] add logging support for exceptions BUG= R=gram@google.com Review URL: https://codereview.chromium.org//17467008 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@24246 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 42 ++++++++++++++-------------- pkgs/logging/test/logging_test.dart | 43 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index b29f076c..3c841dc9 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -153,10 +153,9 @@ class Logger { * [Level.INFO], [Level.WARNING], etc) you can use their specialized methods * instead (e.g. [info], [warning], etc). */ - // TODO(sigmund): add support for logging exceptions. - void log(Level logLevel, String message) { + void log(Level logLevel, String message, [exception]) { if (isLoggable(logLevel)) { - var record = new LogRecord(logLevel, message, fullName); + var record = new LogRecord(logLevel, message, fullName, exception); if (hierarchicalLoggingEnabled) { var target = this; while (target != null) { @@ -170,28 +169,36 @@ class Logger { } /** Log message at level [Level.FINEST]. */ - void finest(String message) => log(Level.FINEST, message); + void finest(String message, [exception]) => + log(Level.FINEST, message, exception); /** Log message at level [Level.FINER]. */ - void finer(String message) => log(Level.FINER, message); + void finer(String message, [exception]) => + log(Level.FINER, message, exception); /** Log message at level [Level.FINE]. */ - void fine(String message) => log(Level.FINE, message); + void fine(String message, [exception]) => + log(Level.FINE, message, exception); /** Log message at level [Level.CONFIG]. */ - void config(String message) => log(Level.CONFIG, message); + void config(String message, [exception]) => + log(Level.CONFIG, message, exception); /** Log message at level [Level.INFO]. */ - void info(String message) => log(Level.INFO, message); + void info(String message, [exception]) => + log(Level.INFO, message, exception); /** Log message at level [Level.WARNING]. */ - void warning(String message) => log(Level.WARNING, message); + void warning(String message, [exception]) => + log(Level.WARNING, message, exception); /** Log message at level [Level.SEVERE]. */ - void severe(String message) => log(Level.SEVERE, message); + void severe(String message, [exception]) => + log(Level.SEVERE, message, exception); /** Log message at level [Level.SHOUT]. */ - void shout(String message) => log(Level.SHOUT, message); + void shout(String message, [exception]) => + log(Level.SHOUT, message, exception); Stream _getStream() { if (hierarchicalLoggingEnabled || parent == null) { @@ -308,14 +315,9 @@ class LogRecord { static int _nextNumber = 0; /** Associated exception (if any) when recording errors messages. */ - Exception exception; + var exception; - /** Associated exception message (if any) when recording errors messages. */ - String exceptionText; - - LogRecord( - this.level, this.message, this.loggerName, - [time, this.exception, this.exceptionText]) : - this.time = (time == null) ? new DateTime.now() : time, - this.sequenceNumber = LogRecord._nextNumber++; + LogRecord(this.level, this.message, this.loggerName, [this.exception]) + : time = new DateTime.now(), + sequenceNumber = LogRecord._nextNumber++; } diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 1af342f5..a631e8c5 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -228,6 +228,49 @@ main() { 'SHOUT: 8'])); }); + test('logging methods store exception', () { + root.level = Level.ALL; + var rootMessages = []; + root.onRecord.listen((r) { + rootMessages.add('${r.level}: ${r.message} ${r.exception}'); + }); + + root.finest('1'); + root.finer('2'); + root.fine('3'); + root.config('4'); + root.info('5'); + root.warning('6'); + root.severe('7'); + root.shout('8'); + root.finest('1', 'a'); + root.finer('2', 'b'); + root.fine('3', ['c']); + root.config('4', 'd'); + root.info('5', 'e'); + root.warning('6', 'f'); + root.severe('7', 'g'); + root.shout('8', 'h'); + + expect(rootMessages, equals([ + 'FINEST: 1 null', + 'FINER: 2 null', + 'FINE: 3 null', + 'CONFIG: 4 null', + 'INFO: 5 null', + 'WARNING: 6 null', + 'SEVERE: 7 null', + 'SHOUT: 8 null', + 'FINEST: 1 a', + 'FINER: 2 b', + 'FINE: 3 [c]', + 'CONFIG: 4 d', + 'INFO: 5 e', + 'WARNING: 6 f', + 'SEVERE: 7 g', + 'SHOUT: 8 h'])); + }); + test('message logging - no hierarchy', () { root.level = Level.WARNING; var rootMessages = []; From de38a7eb111ebc804009a5fa6667fef0330cc0be Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Thu, 4 Jul 2013 13:02:02 +0000 Subject: [PATCH 042/163] Make asBroadcastStream take two callbacks. These callbacks will be called when the broadcast stream no longer has any listeners, or when it gets a listener after having none. The callback is provided with a StreamSubscription-like object where it can pause/resume/cancel the underlying subscription on the original stream. BUG=http://dartbug.com/11289 R=floitsch@google.com Review URL: https://codereview.chromium.org//17490002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@24776 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 3c841dc9..28fbc2fe 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -203,8 +203,8 @@ class Logger { Stream _getStream() { if (hierarchicalLoggingEnabled || parent == null) { if (_controller == null) { - _controller = new StreamController(sync: true); - _stream = _controller.stream.asBroadcastStream(); + _controller = new StreamController.broadcast(sync: true); + _stream = _controller.stream; } return _stream; } else { From 7c55991922573367cb0df4a882cce250acd30bd0 Mon Sep 17 00:00:00 2001 From: "kathyw@google.com" Date: Thu, 22 Aug 2013 22:17:10 +0000 Subject: [PATCH 043/163] Update meta and logging library descriptions; tweak fixnum R=mcampione@google.com Review URL: https://codereview.chromium.org//23220007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@26562 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 28fbc2fe..1eae9104 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -3,25 +3,15 @@ // BSD-style license that can be found in the LICENSE file. /** - * 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. - * - * ## Installing ## - * - * Use [pub][] to install this package. Add the following to your `pubspec.yaml` - * file. + * Support for debugging and error logging. * - * dependencies: - * logging: any - * - * Then run `pub install`. - * - * For more information, see the - * [logging package on pub.dartlang.org][pkg]. + * This library introduces abstractions similar to + * those used in other languages, such as the Closure JS + * Logger and java.util.logging.Logger. * - * [pub]: http://pub.dartlang.org - * [pkg]: http://pub.dartlang.org/packages/logging + * For information on installing and importing this library, see the + * [logging package on pub.dartlang.org] + * (http://pub.dartlang.org/packages/logging). */ library logging; From 64517e7126ffefa988c29bedd24487d49264e499 Mon Sep 17 00:00:00 2001 From: "devoncarew@google.com" Date: Mon, 7 Oct 2013 18:04:47 +0000 Subject: [PATCH 044/163] Add a toString() to LogRecord. R=sigmund@google.com Review URL: https://codereview.chromium.org//24341002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@28317 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 1eae9104..33761453 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -310,4 +310,6 @@ class LogRecord { LogRecord(this.level, this.message, this.loggerName, [this.exception]) : time = new DateTime.now(), sequenceNumber = LogRecord._nextNumber++; + + String toString() => '[${level.name}] $loggerName: $message'; } From 7653e23a5441360e53d3ff86e765123cb2eaf9f2 Mon Sep 17 00:00:00 2001 From: "kevmoo@j832.com" Date: Sun, 27 Oct 2013 17:38:45 +0000 Subject: [PATCH 045/163] pkg/logging: added stackTrace support Plus: * don't expose mutable children collection from Logger * remove superfluous field * other tweaks BUG=https://code.google.com/p/dart/issues/detail?id=14416 R=sethladd@google.com, sigmund@google.com Review URL: https://codereview.chromium.org//46233002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@29324 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 107 ++++++++++++++++------------ pkgs/logging/pubspec.yaml | 3 + pkgs/logging/test/logging_test.dart | 75 +++++++++++++++---- 3 files changed, 124 insertions(+), 61 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 33761453..071b496c 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -5,9 +5,8 @@ /** * Support 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. + * This library introduces abstractions similar to those used in other + * languages, such as the Closure JS Logger and java.util.logging.Logger. * * For information on installing and importing this library, see the * [logging package on pub.dartlang.org] @@ -16,6 +15,8 @@ library logging; import 'dart:async'; +import 'package:meta/meta.dart'; +import 'package:unmodifiable_collection/unmodifiable_collection.dart'; /** * Whether to allow fine-grain logging and configuration of loggers in a @@ -48,26 +49,26 @@ class Logger { /** Logging [Level] used for entries generated on this logger. */ Level _level; + final Map _children; + /** Children in the hierarchy of loggers, indexed by their simple names. */ - Map children; + final Map children; /** Controller used to notify when log entries are added to this logger. */ StreamController _controller; - /** The broadcast stream associated with the controller. */ - Stream _stream; - /** * Singleton constructor. Calling `new Logger(name)` will return the same * actual instance whenever it is called with the same string name. */ factory Logger(String name) { + return _loggers.putIfAbsent(name, () => new Logger._named(name)); + } + + factory Logger._named(String name) { if (name.startsWith('.')) { throw new ArgumentError("name shouldn't start with a '.'"); } - if (_loggers == null) _loggers = {}; - if (_loggers.containsKey(name)) return _loggers[name]; - // Split hierarchical names (separated with '.'). int dot = name.lastIndexOf('.'); Logger parent = null; @@ -79,14 +80,13 @@ class Logger { parent = new Logger(name.substring(0, dot)); thisName = name.substring(dot + 1); } - final res = new Logger._internal(thisName, parent); - _loggers[name] = res; - return res; + return new Logger._internal(thisName, parent, new Map()); } - Logger._internal(this.name, this.parent) - : children = new Map() { - if (parent != null) parent.children[name] = this; + Logger._internal(this.name, this.parent, Map children) : + this._children = children, + this.children = new UnmodifiableMapView(children) { + if (parent != null) parent._children[name] = this; } /** @@ -102,7 +102,7 @@ class Logger { } /** Override the level for this particular [Logger] and its children. */ - set level(Level value) { + void set level(Level value) { if (hierarchicalLoggingEnabled && parent != null) { _level = value; } else { @@ -138,14 +138,18 @@ class Logger { /** * Adds a log record for a [message] at a particular [logLevel] if - * `isLoggable(logLevel)` is true. Use this method to create log entries for - * user-defined levels. To record a message at a predefined level (e.g. - * [Level.INFO], [Level.WARNING], etc) you can use their specialized methods - * instead (e.g. [info], [warning], etc). + * `isLoggable(logLevel)` is true. + * + * Use this method to create log entries for user-defined levels. To record a + * message at a predefined level (e.g. [Level.INFO], [Level.WARNING], etc) you + * can use their specialized methods instead (e.g. [info], [warning], etc). */ - void log(Level logLevel, String message, [exception]) { + void log(Level logLevel, String message, [Object error, + StackTrace stackTrace]) { if (isLoggable(logLevel)) { - var record = new LogRecord(logLevel, message, fullName, exception); + var record = new LogRecord(logLevel, message, fullName, error, + stackTrace); + if (hierarchicalLoggingEnabled) { var target = this; while (target != null) { @@ -159,44 +163,43 @@ class Logger { } /** Log message at level [Level.FINEST]. */ - void finest(String message, [exception]) => - log(Level.FINEST, message, exception); + void finest(String message, [Object error, StackTrace stackTrace]) => + log(Level.FINEST, message, error, stackTrace); /** Log message at level [Level.FINER]. */ - void finer(String message, [exception]) => - log(Level.FINER, message, exception); + void finer(String message, [Object error, StackTrace stackTrace]) => + log(Level.FINER, message, error, stackTrace); /** Log message at level [Level.FINE]. */ - void fine(String message, [exception]) => - log(Level.FINE, message, exception); + void fine(String message, [Object error, StackTrace stackTrace]) => + log(Level.FINE, message, error, stackTrace); /** Log message at level [Level.CONFIG]. */ - void config(String message, [exception]) => - log(Level.CONFIG, message, exception); + void config(String message, [Object error, StackTrace stackTrace]) => + log(Level.CONFIG, message, error, stackTrace); /** Log message at level [Level.INFO]. */ - void info(String message, [exception]) => - log(Level.INFO, message, exception); + void info(String message, [Object error, StackTrace stackTrace]) => + log(Level.INFO, message, error, stackTrace); /** Log message at level [Level.WARNING]. */ - void warning(String message, [exception]) => - log(Level.WARNING, message, exception); + void warning(String message, [Object error, StackTrace stackTrace]) => + log(Level.WARNING, message, error, stackTrace); /** Log message at level [Level.SEVERE]. */ - void severe(String message, [exception]) => - log(Level.SEVERE, message, exception); + void severe(String message, [Object error, StackTrace stackTrace]) => + log(Level.SEVERE, message, error, stackTrace); /** Log message at level [Level.SHOUT]. */ - void shout(String message, [exception]) => - log(Level.SHOUT, message, exception); + void shout(String message, [Object error, StackTrace stackTrace]) => + log(Level.SHOUT, message, error, stackTrace); Stream _getStream() { if (hierarchicalLoggingEnabled || parent == null) { if (_controller == null) { _controller = new StreamController.broadcast(sync: true); - _stream = _controller.stream; } - return _stream; + return _controller.stream; } else { return root._getStream(); } @@ -212,7 +215,7 @@ class Logger { static Logger get root => new Logger(''); /** All [Logger]s in the system. */ - static Map _loggers; + static final Map _loggers = {}; } @@ -233,7 +236,6 @@ typedef void LoggerHandler(LogRecord); */ class Level implements Comparable { - // TODO(sigmund): mark name/value as 'const' when the language supports it. final String name; /** @@ -274,7 +276,7 @@ class Level implements Comparable { /** Key for extra debugging loudness ([value] = 1200). */ static const Level SHOUT = const Level('SHOUT', 1200); - bool operator ==(Level other) => other != null && value == other.value; + bool operator ==(Object other) => other is Level && value == other.value; bool operator <(Level other) => value < other.value; bool operator <=(Level other) => value <= other.value; bool operator >(Level other) => value > other.value; @@ -304,10 +306,21 @@ class LogRecord { static int _nextNumber = 0; - /** Associated exception (if any) when recording errors messages. */ - var exception; + /** Associated error (if any) when recording errors messages. */ + final Object error; + + // TODO(kevmoo) - remove before V1 + /** + * DEPRECATED. Use [error] instead. + */ + @deprecated + Object get exception => error; + + /** Associated stackTrace (if any) when recording errors messages. */ + final StackTrace stackTrace; - LogRecord(this.level, this.message, this.loggerName, [this.exception]) + LogRecord(this.level, this.message, this.loggerName, [this.error, + this.stackTrace]) : time = new DateTime.now(), sequenceNumber = LogRecord._nextNumber++; diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 37ed46e6..c23bd3ef 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -3,5 +3,8 @@ author: Dart Team 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: + meta: any + unmodifiable_collection: any dev_dependencies: unittest: any diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index a631e8c5..1c973503 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -24,8 +24,8 @@ main() { expect(level2 > level1, isTrue); var level3 = const Level('NOT_REAL3', 253); - expect(!identical(level1, level3), isTrue); // different instances - expect(level1 == level3, isTrue); // same value. + expect(level1, isNot(same(level3))); // different instances + expect(level1, equals(level3)); // same value. }); test('default levels are in order', () { @@ -60,8 +60,8 @@ main() { var map = new Map(); map[Level.INFO] = 'info'; map[Level.SHOUT] = 'shout'; - expect(map[Level.INFO], equals('info')); - expect(map[Level.SHOUT], equals('shout')); + expect(map[Level.INFO], same('info')); + expect(map[Level.SHOUT], same('shout')); }); test('logger name cannot start with a "." ', () { @@ -90,10 +90,10 @@ main() { Logger a = new Logger('a'); Logger b = new Logger('a.b'); Logger c = new Logger('a.c'); - expect(a == b.parent, isTrue); - expect(a == c.parent, isTrue); - expect(a.children['b'] == b, isTrue); - expect(a.children['c'] == c, isTrue); + expect(a, same(b.parent)); + expect(a, same(c.parent)); + expect(a.children['b'], same(b)); + expect(a.children['c'], same(c)); }); test('loggers are singletons', () { @@ -101,10 +101,57 @@ main() { Logger a2 = new Logger('a'); Logger b = new Logger('a.b'); Logger root = Logger.root; - expect(identical(a1, a2), isTrue); - expect(identical(a1, b.parent), isTrue); - expect(identical(root, a1.parent), isTrue); - expect(identical(root, new Logger('')), isTrue); + expect(a1, same(a2)); + expect(a1, same(b.parent)); + expect(root, same(a1.parent)); + expect(root, same(new Logger(''))); + }); + + test('cannot directly manipulate Logger.children', () { + var loggerAB = new Logger('a.b'); + var loggerA = loggerAB.parent; + + expect(loggerA.children['b'], same(loggerAB), reason: 'can read Children'); + + expect(() { + loggerAB.children['test'] = null; + }, throwsUnsupportedError, reason: 'Children is read-only'); + }); + + test('stackTrace gets throw to LogRecord', () { + Logger.root.level = Level.INFO; + + var records = new List(); + + var sub = Logger.root.onRecord.listen(records.add); + + try { + throw new UnsupportedError('test exception'); + } catch(error, stack) { + Logger.root.log(Level.SEVERE, 'severe', error, stack); + Logger.root.warning('warning', error, stack); + } + + Logger.root.log(Level.SHOUT, 'shout'); + + sub.cancel(); + + expect(records, hasLength(3)); + + var severe = records[0]; + expect(severe.message, 'severe'); + expect(severe.error is UnsupportedError, isTrue); + expect(severe.stackTrace is StackTrace, isTrue); + + var warning = records[1]; + expect(warning.message, 'warning'); + expect(warning.error is UnsupportedError, isTrue); + expect(warning.stackTrace is StackTrace, isTrue); + + var shout = records[2]; + expect(shout.message, 'shout'); + expect(shout.error, isNull); + expect(shout.stackTrace, isNull); }); group('mutating levels', () { @@ -134,7 +181,7 @@ main() { }); test('cannot set level if hierarchy is disabled', () { - expect(() {a.level = Level.FINE;}, throws); + expect(() {a.level = Level.FINE;}, throwsUnsupportedError); }); test('loggers effective level - no hierarchy', () { @@ -176,7 +223,7 @@ main() { expect(root.isLoggable(Level.WARNING), isFalse); expect(c.isLoggable(Level.FINEST), isTrue); expect(c.isLoggable(Level.FINE), isTrue); - expect(!e.isLoggable(Level.SHOUT), isTrue); + expect(e.isLoggable(Level.SHOUT), isFalse); }); test('add/remove handlers - no hierarchy', () { From 3f74838af5d92e733fb104be8616455b6c8280e4 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Tue, 29 Oct 2013 12:00:44 +0000 Subject: [PATCH 046/163] Remove @deprecated features. R=alanknight@google.com, rnystrom@google.com, sgjesse@google.com Review URL: https://codereview.chromium.org//48293002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@29438 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 7 ------- pkgs/logging/test/logging_test.dart | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 071b496c..f3b1822b 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -309,13 +309,6 @@ class LogRecord { /** Associated error (if any) when recording errors messages. */ final Object error; - // TODO(kevmoo) - remove before V1 - /** - * DEPRECATED. Use [error] instead. - */ - @deprecated - Object get exception => error; - /** Associated stackTrace (if any) when recording errors messages. */ final StackTrace stackTrace; diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 1c973503..a188bb5e 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -279,7 +279,7 @@ main() { root.level = Level.ALL; var rootMessages = []; root.onRecord.listen((r) { - rootMessages.add('${r.level}: ${r.message} ${r.exception}'); + rootMessages.add('${r.level}: ${r.message} ${r.error}'); }); root.finest('1'); From 8e00240445cb645f978030ea94588bc193b7c556 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Tue, 29 Oct 2013 12:54:37 +0000 Subject: [PATCH 047/163] Revert "Remove @deprecated features." There were more uses of the deprecated features. Review URL: https://codereview.chromium.org//50313004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@29443 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 7 +++++++ pkgs/logging/test/logging_test.dart | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index f3b1822b..071b496c 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -309,6 +309,13 @@ class LogRecord { /** Associated error (if any) when recording errors messages. */ final Object error; + // TODO(kevmoo) - remove before V1 + /** + * DEPRECATED. Use [error] instead. + */ + @deprecated + Object get exception => error; + /** Associated stackTrace (if any) when recording errors messages. */ final StackTrace stackTrace; diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index a188bb5e..1c973503 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -279,7 +279,7 @@ main() { root.level = Level.ALL; var rootMessages = []; root.onRecord.listen((r) { - rootMessages.add('${r.level}: ${r.message} ${r.error}'); + rootMessages.add('${r.level}: ${r.message} ${r.exception}'); }); root.finest('1'); From 5c06caef2237eb2142d4dd93f94e82ceb1c57adb Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Wed, 30 Oct 2013 10:25:08 +0000 Subject: [PATCH 048/163] Add @proxy to annotations.dart. Remove package:meta R=bak@google.com, brianwilkerson@google.com Review URL: https://codereview.chromium.org//46593003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@29525 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 071b496c..bf0e1a19 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -15,7 +15,6 @@ library logging; import 'dart:async'; -import 'package:meta/meta.dart'; import 'package:unmodifiable_collection/unmodifiable_collection.dart'; /** From 4ec85e0731f594c1c03c52e9b98f24b521624a38 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Wed, 30 Oct 2013 12:09:15 +0000 Subject: [PATCH 049/163] Reapply "Remove @deprecated features." R=scheglov@google.com, sgjesse@google.com Review URL: https://codereview.chromium.org//50413005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@29535 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 7 ------- pkgs/logging/test/logging_test.dart | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index bf0e1a19..efbe9ba2 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -308,13 +308,6 @@ class LogRecord { /** Associated error (if any) when recording errors messages. */ final Object error; - // TODO(kevmoo) - remove before V1 - /** - * DEPRECATED. Use [error] instead. - */ - @deprecated - Object get exception => error; - /** Associated stackTrace (if any) when recording errors messages. */ final StackTrace stackTrace; diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 1c973503..a188bb5e 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -279,7 +279,7 @@ main() { root.level = Level.ALL; var rootMessages = []; root.onRecord.listen((r) { - rootMessages.add('${r.level}: ${r.message} ${r.exception}'); + rootMessages.add('${r.level}: ${r.message} ${r.error}'); }); root.finest('1'); From 28a03cb06ca7f4d5a5274d08e2ff47277b7cfebc Mon Sep 17 00:00:00 2001 From: "sethladd@google.com" Date: Fri, 1 Nov 2013 18:01:28 +0000 Subject: [PATCH 050/163] add useful docs for logging BUG= R=kevmoo@j832.com Review URL: https://codereview.chromium.org//55853003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@29761 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 44 +++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index efbe9ba2..25213bbb 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -3,14 +3,50 @@ // BSD-style license that can be found in the LICENSE file. /** - * Support 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. + * Support for logging. * * For information on installing and importing this library, see the * [logging package on pub.dartlang.org] * (http://pub.dartlang.org/packages/logging). + * + * ## 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`. + * + * Logger.root.level = Level.ALL; + * Logger.root.onRecord.listen((LogRecord rec) { + * print('${rec.level.name}: ${rec.time}: ${rec.message}'); + * }); + * + * First, set the root [Level]. All messages at or above the level are + * sent to the [onRecord] stream. + * + * Then, listen on the [onRecord] stream for [LogRecord] events. The + * [LogRecord] class has various properties for the message, error, + * logger name, and more. + * + * ## Logging messages + * + * Create a [Logger] with a unique name to easily identify the source + * of the log messages. + * + * final Logger log = new Logger('MyClassName'); + * + * Here is an example of logging a debug message and an error: + * + * Future future = doSomethingAsync(); + * future.then((result) { + * log.fine('Got the result: $result'); + * processResult(result); + * }) + * .catchError((e, stackTrace) => log.severe('Oh noes!', e, stackTrace)); + * + * See the [Logger] class for the different logging methods. */ library logging; From dd83bc1e332be40a67d68b07c0fb1ffdeacbd948 Mon Sep 17 00:00:00 2001 From: "jmesserly@google.com" Date: Wed, 6 Nov 2013 03:27:58 +0000 Subject: [PATCH 051/163] add versions and constraints for packages and samples - all packages at 0.9.0, except "analyzer" which had a version already - dependencies at ">=0.9.0 <0.10.0" except analyzer is ">=0.10.0 <0.11.0" - sdk constraint ">=1.0.0 <2.0.0" R=sigmund@google.com Review URL: https://codereview.chromium.org//59763006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@29957 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/pubspec.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index c23bd3ef..47c7e9eb 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,10 +1,12 @@ name: logging +version: 0.9.0 author: Dart Team 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: - meta: any - unmodifiable_collection: any + unmodifiable_collection: ">=0.9.0 <0.10.0" dev_dependencies: - unittest: any + unittest: ">=0.9.0 <0.10.0" +environment: + sdk: ">=1.0.0 <2.0.0" From 3b035782e7d4243e59c9c3d43c794aa87706d28f Mon Sep 17 00:00:00 2001 From: "ajohnsen@google.com" Date: Wed, 6 Nov 2013 09:09:18 +0000 Subject: [PATCH 052/163] Revert "add versions and constraints for packages and samples" This is currently blocking us from testing samples. BUG= R=kasperl@google.com Review URL: https://codereview.chromium.org//59513007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@29960 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/pubspec.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 47c7e9eb..c23bd3ef 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,12 +1,10 @@ name: logging -version: 0.9.0 author: Dart Team 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: - unmodifiable_collection: ">=0.9.0 <0.10.0" + meta: any + unmodifiable_collection: any dev_dependencies: - unittest: ">=0.9.0 <0.10.0" -environment: - sdk: ">=1.0.0 <2.0.0" + unittest: any From 61739cbe09fb21bb4af694194bc95af3dbeb2c8f Mon Sep 17 00:00:00 2001 From: "dgrove@google.com" Date: Wed, 6 Nov 2013 18:28:22 +0000 Subject: [PATCH 053/163] Re-land r29957 (add versions and constraints for packages and samples), with SDK constraints bumped from 1.0.0 to 0.8.10+6 . R=ricow@google.com, sigmund@google.com Review URL: https://codereview.chromium.org//62473002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@29986 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/pubspec.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index c23bd3ef..78935236 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,10 +1,12 @@ name: logging +version: 0.9.0 author: Dart Team 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: - meta: any - unmodifiable_collection: any + unmodifiable_collection: ">=0.9.0 <0.10.0" dev_dependencies: - unittest: any + unittest: ">=0.9.0 <0.10.0" +environment: + sdk: ">=0.8.10+6 <2.0.0" From 7599a0bf88be40eec22918bbffaf255d2a066243 Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Tue, 19 Nov 2013 12:11:24 +0000 Subject: [PATCH 054/163] Combine unmodifiable_collection package into collection_helpers. Avoids some duplicated code, and makes everything much simpler. R=floitsch@google.com Review URL: https://codereview.chromium.org//70073003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@30402 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- pkgs/logging/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 25213bbb..37ac67d4 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -51,7 +51,7 @@ library logging; import 'dart:async'; -import 'package:unmodifiable_collection/unmodifiable_collection.dart'; +import 'package:collection_helpers/wrappers.dart'; /** * Whether to allow fine-grain logging and configuration of loggers in a diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 78935236..d298608e 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -5,7 +5,7 @@ description: Provides APIs for debugging and error logging. This library introdu homepage: http://www.dartlang.org documentation: http://api.dartlang.org/docs/pkg/logging dependencies: - unmodifiable_collection: ">=0.9.0 <0.10.0" + collection_helpers: ">=0.9.0 <0.10.0" dev_dependencies: unittest: ">=0.9.0 <0.10.0" environment: From 8bbc7321fe49401995df8885a1716451a2ee1355 Mon Sep 17 00:00:00 2001 From: "kevmoo@j832.com" Date: Tue, 26 Nov 2013 20:50:42 +0000 Subject: [PATCH 055/163] 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 --- pkgs/logging/lib/logging.dart | 3 +++ pkgs/logging/pubspec.yaml | 10 +++++----- pkgs/logging/test/logging_test.dart | 16 ++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 37ac67d4..8bff36b4 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -311,6 +311,9 @@ class Level implements Comparable { /** Key for extra debugging loudness ([value] = 1200). */ static const Level SHOUT = const Level('SHOUT', 1200); + static const List 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/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index d298608e..334113f0 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,12 +1,12 @@ name: logging -version: 0.9.0 +version: 0.9.1-dev author: Dart Team 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 +environment: + sdk: '>=0.8.10+6 <2.0.0' dependencies: - collection_helpers: ">=0.9.0 <0.10.0" + collection_helpers: '>=0.9.1 <0.10.0' dev_dependencies: - unittest: ">=0.9.0 <0.10.0" -environment: - sdk: ">=0.8.10+6 <2.0.0" + unittest: '>=0.9.0 <0.10.0' diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index a188bb5e..82ef3e12 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -29,10 +29,7 @@ main() { }); 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 @@ main() { 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 @@ main() { }); test('logger name cannot start with a "." ', () { - expect(() => new Logger('.c'), throws); + expect(() => new Logger('.c'), throwsArgumentError); }); test('logger naming is hierarchical', () { From 1ddb9647bb5acc9d6075400a44fa8f59029b4983 Mon Sep 17 00:00:00 2001 From: "jmesserly@google.com" Date: Wed, 11 Dec 2013 01:41:02 +0000 Subject: [PATCH 056/163] update pubspecs for pkg uploading R=sigmund@google.com Review URL: https://codereview.chromium.org//112283002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@31053 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/pubspec.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 334113f0..098558c4 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,11 +1,14 @@ name: logging -version: 0.9.1-dev +version: 0.9.1 author: Dart Team -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. +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 environment: - sdk: '>=0.8.10+6 <2.0.0' + sdk: '>=1.0.0 <2.0.0' dependencies: collection_helpers: '>=0.9.1 <0.10.0' dev_dependencies: From ecdaebe23f4d55bf23696572e3fe135cd458b82d Mon Sep 17 00:00:00 2001 From: "jmesserly@google.com" Date: Wed, 11 Dec 2013 01:56:04 +0000 Subject: [PATCH 057/163] add LICENSE AUTHORS PATENTS so we can publish R=sigmund@google.com Review URL: https://codereview.chromium.org//105693012 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@31055 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/AUTHORS | 9 +++++++++ pkgs/logging/LICENSE | 26 ++++++++++++++++++++++++++ pkgs/logging/PATENTS | 23 +++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 pkgs/logging/AUTHORS create mode 100644 pkgs/logging/LICENSE create mode 100644 pkgs/logging/PATENTS diff --git a/pkgs/logging/AUTHORS b/pkgs/logging/AUTHORS new file mode 100644 index 00000000..06177657 --- /dev/null +++ b/pkgs/logging/AUTHORS @@ -0,0 +1,9 @@ +# Names should be added to this file with this pattern: +# +# For individuals: +# Name +# +# For organizations: +# Organization +# +Google Inc. <*@google.com> diff --git a/pkgs/logging/LICENSE b/pkgs/logging/LICENSE new file mode 100644 index 00000000..ee999303 --- /dev/null +++ b/pkgs/logging/LICENSE @@ -0,0 +1,26 @@ +Copyright 2013, the Dart project authors. All rights reserved. +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 Inc. 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. diff --git a/pkgs/logging/PATENTS b/pkgs/logging/PATENTS new file mode 100644 index 00000000..69541968 --- /dev/null +++ b/pkgs/logging/PATENTS @@ -0,0 +1,23 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Dart Project. + +Google hereby grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this +section) patent license to make, have made, use, offer to sell, sell, +import, transfer, and otherwise run, modify and propagate the contents +of this implementation of Dart, where such license applies only to +those patent claims, both currently owned by Google and acquired in +the future, licensable by Google that are necessarily infringed by +this implementation of Dart. This grant does not include claims that +would be infringed only as a consequence of further modification of +this implementation. If you or your agent or exclusive licensee +institute or order or agree to the institution of patent litigation +against any entity (including a cross-claim or counterclaim in a +lawsuit) alleging that this implementation of Dart or any code +incorporated within this implementation of Dart constitutes direct or +contributory patent infringement, or inducement of patent +infringement, then any patent rights granted to you under this License +for this implementation of Dart shall terminate as of the date such +litigation is filed. From 865af310e8250552a45145883464b9c34815b50b Mon Sep 17 00:00:00 2001 From: "lrn@google.com" Date: Thu, 19 Dec 2013 11:57:56 +0000 Subject: [PATCH 058/163] Create associated packages for the dart:collection and dart:async libs. R=sgjesse@google.com Review URL: https://codereview.chromium.org//113883002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@31260 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/lib/logging.dart | 2 +- pkgs/logging/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 8bff36b4..ba342f7a 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -51,7 +51,7 @@ library logging; import 'dart:async'; -import 'package:collection_helpers/wrappers.dart'; +import 'package:collection/wrappers.dart'; /** * Whether to allow fine-grain logging and configuration of loggers in a diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 098558c4..ef3a4ccc 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -10,6 +10,6 @@ documentation: http://api.dartlang.org/docs/pkg/logging environment: sdk: '>=1.0.0 <2.0.0' dependencies: - collection_helpers: '>=0.9.1 <0.10.0' + collection: '>=0.9.0 <0.10.0' dev_dependencies: unittest: '>=0.9.0 <0.10.0' From ba55eb6c8a3a488e130d0ef61ccf7ab337415d51 Mon Sep 17 00:00:00 2001 From: "kevmoo@google.com" Date: Fri, 27 Dec 2013 17:20:00 +0000 Subject: [PATCH 059/163] flagging pkg/args and pkg/logging as dev+1 should be publishing with bumped version due to package constraint changes R=rnystrom@google.com Review URL: https://codereview.chromium.org//102833012 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@31388 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index ef3a4ccc..199f6539 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.9.1 +version: 0.9.1+1 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces From 26480d68bd41301b246e174b6fd9a75ae6b00fec Mon Sep 17 00:00:00 2001 From: "kevmoo@google.com" Date: Thu, 24 Jul 2014 17:44:30 +0000 Subject: [PATCH 060/163] pkg/logging: use UnmodifiableMapView from dart:collection remove documentation URL remove (now) unused collection pkg import move intro docs to README.md R=sethladd@google.com Review URL: https://codereview.chromium.org//413193002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@38546 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/README.md | 42 ++++++++++++++++++++++++++++++++ pkgs/logging/lib/logging.dart | 46 +---------------------------------- pkgs/logging/pubspec.yaml | 11 +++------ 3 files changed, 47 insertions(+), 52 deletions(-) create mode 100644 pkgs/logging/README.md diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md new file mode 100644 index 00000000..9d6c9781 --- /dev/null +++ b/pkgs/logging/README.md @@ -0,0 +1,42 @@ +## 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; +Logger.root.onRecord.listen((LogRecord rec) { + print('${rec.level.name}: ${rec.time}: ${rec.message}'); +}); +``` + +First, set the root [Level]. All messages at or above the level are +sent to the [onRecord] stream. + +Then, listen on the [onRecord] stream for [LogRecord] events. The +[LogRecord] class has various properties for the message, error, +logger name, and more. + +## Logging messages + +Create a [Logger] with a unique name to easily identify the source +of the log messages. + +```dart +final Logger log = new 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)); +``` + +See the [Logger] class for the different logging methods. diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index ba342f7a..d1fb4524 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -3,55 +3,11 @@ // BSD-style license that can be found in the LICENSE file. /** - * Support for logging. - * - * For information on installing and importing this library, see the - * [logging package on pub.dartlang.org] - * (http://pub.dartlang.org/packages/logging). - * - * ## 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`. - * - * Logger.root.level = Level.ALL; - * Logger.root.onRecord.listen((LogRecord rec) { - * print('${rec.level.name}: ${rec.time}: ${rec.message}'); - * }); - * - * First, set the root [Level]. All messages at or above the level are - * sent to the [onRecord] stream. - * - * Then, listen on the [onRecord] stream for [LogRecord] events. The - * [LogRecord] class has various properties for the message, error, - * logger name, and more. - * - * ## Logging messages - * - * Create a [Logger] with a unique name to easily identify the source - * of the log messages. - * - * final Logger log = new Logger('MyClassName'); - * - * Here is an example of logging a debug message and an error: - * - * Future future = doSomethingAsync(); - * future.then((result) { - * log.fine('Got the result: $result'); - * processResult(result); - * }) - * .catchError((e, stackTrace) => log.severe('Oh noes!', e, stackTrace)); - * - * See the [Logger] class for the different logging methods. */ library logging; import 'dart:async'; -import 'package:collection/wrappers.dart'; +import 'dart:collection'; /** * Whether to allow fine-grain logging and configuration of loggers in a diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 199f6539..678ceef6 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,15 +1,12 @@ name: logging -version: 0.9.1+1 +version: 0.9.1+2 author: Dart Team 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 +homepage: https://pub.dartlang.org/packages/logging environment: - sdk: '>=1.0.0 <2.0.0' -dependencies: - collection: '>=0.9.0 <0.10.0' + sdk: '>=1.5.0 <2.0.0' dev_dependencies: - unittest: '>=0.9.0 <0.10.0' + unittest: '>=0.9.0 <0.12.0' From 05bdd75e5e4e20b5e7488fa7f1017e1faa48a7f7 Mon Sep 17 00:00:00 2001 From: "jakemac@google.com" Date: Fri, 25 Jul 2014 18:35:00 +0000 Subject: [PATCH 061/163] updated logging package to accept functions or other non-string objects when logging R=sigmund@google.com Review URL: https://codereview.chromium.org//420553007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/logging@38584 260f80e4-7a28-3924-810f-c04153c831b5 --- pkgs/logging/README.md | 7 ++++++ pkgs/logging/lib/logging.dart | 28 +++++++++++++-------- pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 38 +++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 11 deletions(-) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 9d6c9781..f4781a7a 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -39,4 +39,11 @@ var future = doSomethingAsync().then((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("-")); +``` + See the [Logger] class for the different logging methods. diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index d1fb4524..5f4bc2be 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -134,10 +134,18 @@ class Logger { * Use this method to create log entries for user-defined levels. To record a * message at a predefined level (e.g. [Level.INFO], [Level.WARNING], etc) you * can use their specialized methods instead (e.g. [info], [warning], etc). + * + * If [message] is a [Function], it will be lazy evaluated. Additionally, if + * [message] or its evaluated value is not a [String], then 'toString()' will + * be called on it and the result will be logged. */ - void log(Level logLevel, String message, [Object error, - StackTrace stackTrace]) { + void log(Level logLevel, message, [Object error, StackTrace stackTrace]) { if (isLoggable(logLevel)) { + // If message is a Function, evaluate it. + if (message is Function) message = message(); + // If message is still not a String, call toString(). + if (message is! String) message = message.toString(); + var record = new LogRecord(logLevel, message, fullName, error, stackTrace); @@ -154,35 +162,35 @@ class Logger { } /** Log message at level [Level.FINEST]. */ - void finest(String message, [Object error, StackTrace stackTrace]) => + void finest(message, [Object error, StackTrace stackTrace]) => log(Level.FINEST, message, error, stackTrace); /** Log message at level [Level.FINER]. */ - void finer(String message, [Object error, StackTrace stackTrace]) => + void finer(message, [Object error, StackTrace stackTrace]) => log(Level.FINER, message, error, stackTrace); /** Log message at level [Level.FINE]. */ - void fine(String message, [Object error, StackTrace stackTrace]) => + void fine(message, [Object error, StackTrace stackTrace]) => log(Level.FINE, message, error, stackTrace); /** Log message at level [Level.CONFIG]. */ - void config(String message, [Object error, StackTrace stackTrace]) => + void config(message, [Object error, StackTrace stackTrace]) => log(Level.CONFIG, message, error, stackTrace); /** Log message at level [Level.INFO]. */ - void info(String message, [Object error, StackTrace stackTrace]) => + void info(message, [Object error, StackTrace stackTrace]) => log(Level.INFO, message, error, stackTrace); /** Log message at level [Level.WARNING]. */ - void warning(String message, [Object error, StackTrace stackTrace]) => + void warning(message, [Object error, StackTrace stackTrace]) => log(Level.WARNING, message, error, stackTrace); /** Log message at level [Level.SEVERE]. */ - void severe(String message, [Object error, StackTrace stackTrace]) => + void severe(message, [Object error, StackTrace stackTrace]) => log(Level.SEVERE, message, error, stackTrace); /** Log message at level [Level.SHOUT]. */ - void shout(String message, [Object error, StackTrace stackTrace]) => + void shout(message, [Object error, StackTrace stackTrace]) => log(Level.SHOUT, message, error, stackTrace); Stream _getStream() { diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 678ceef6..dd7ba7c2 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.9.1+2 +version: 0.9.2 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 82ef3e12..223498f0 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -418,5 +418,43 @@ main() { 'WARNING: 9', 'SHOUT: 10'])); }); + + test('message logging - lazy functions', () { + root.level = Level.INFO; + var messages = []; + root.onRecord.listen((record) { + messages.add('${record.level}: ${record.message}'); + }); + + var callCount = 0; + var myClosure = () => "${++callCount}"; + + root.info(myClosure); + root.finer(myClosure); // Should not get evaluated. + root.warning(myClosure); + + expect(messages, equals([ + 'INFO: 1', + 'WARNING: 2',])); + }); + + test('message logging - calls toString', () { + root.level = Level.INFO; + var messages = []; + root.onRecord.listen((record) { + messages.add('${record.level}: ${record.message}'); + }); + + root.info(5); + root.info(false); + root.info([1, 2, 3]); + root.info(() => 10); + + expect(messages, equals([ + 'INFO: 5', + 'INFO: false', + 'INFO: [1, 2, 3]', + 'INFO: 10',])); + }); }); } From b36768774a9c6ce8b54179ca22177fc7cb9e2d7b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 19 Dec 2014 13:55:46 -0800 Subject: [PATCH 062/163] Update the pubspec's homepage link. --- pkgs/logging/.gitignore | 14 ++++++++++++++ pkgs/logging/.status | 15 +++++++++++++++ pkgs/logging/codereview.settings | 3 +++ pkgs/logging/pubspec.yaml | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 pkgs/logging/.gitignore create mode 100644 pkgs/logging/.status create mode 100644 pkgs/logging/codereview.settings diff --git a/pkgs/logging/.gitignore b/pkgs/logging/.gitignore new file mode 100644 index 00000000..388eff0b --- /dev/null +++ b/pkgs/logging/.gitignore @@ -0,0 +1,14 @@ +# Don’t commit the following directories created by pub. +.buildlog +.pub/ +build/ +packages + +# Or the files created by dart2js. +*.dart.js +*.js_ +*.js.deps +*.js.map + +# Include when developing application packages. +pubspec.lock \ No newline at end of file diff --git a/pkgs/logging/.status b/pkgs/logging/.status new file mode 100644 index 00000000..ff095a2f --- /dev/null +++ b/pkgs/logging/.status @@ -0,0 +1,15 @@ +# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +# 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. + +# Skip non-test files ending with "_test". +packages/*: Skip +*/packages/*: Skip +*/*/packages/*: Skip +*/*/*/packages/*: Skip +*/*/*/*packages/*: Skip +*/*/*/*/*packages/*: Skip + +# Only run tests from the build directory, since we don't care about the +# difference between transformed an untransformed code. +test/*: Skip diff --git a/pkgs/logging/codereview.settings b/pkgs/logging/codereview.settings new file mode 100644 index 00000000..ae2cae66 --- /dev/null +++ b/pkgs/logging/codereview.settings @@ -0,0 +1,3 @@ +CODE_REVIEW_SERVER: http://codereview.chromium.org/ +VIEW_VC: https://github.com/dart-lang/logging/commit/ +CC_LIST: reviews@dartlang.org \ No newline at end of file diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index dd7ba7c2..5a0b86fa 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -5,7 +5,7 @@ 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: https://pub.dartlang.org/packages/logging +homepage: https://github.com/dart-lang/logging environment: sdk: '>=1.5.0 <2.0.0' dev_dependencies: From f19d447786f30dbf08b75d71e6e9eaccdf3dfe60 Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Tue, 23 Dec 2014 13:54:08 -0800 Subject: [PATCH 063/163] Make type signature consistent with class Object BUG= R=sigmund@google.com Review URL: https://codereview.chromium.org//823613004 --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 5f4bc2be..dc83d848 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -278,7 +278,7 @@ class Level implements Comparable { static const List LEVELS = const [ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, SHOUT, OFF]; - bool operator ==(Object other) => other is Level && value == other.value; + bool operator ==(other) => other is Level && value == other.value; bool operator <(Level other) => value < other.value; bool operator <=(Level other) => value <= other.value; bool operator >(Level other) => value > other.value; From c0b34976287929e916606bd098ad64c8f2488997 Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Wed, 7 Jan 2015 13:51:19 +0100 Subject: [PATCH 064/163] Adding a "zone" value to "class LogRecord" R=sgjesse@google.com, wibling@google.com Review URL: https://codereview.chromium.org//786813002 --- pkgs/logging/CHANGELOG.md | 6 ++++ pkgs/logging/lib/logging.dart | 20 ++++++++++-- pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 49 +++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 pkgs/logging/CHANGELOG.md diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md new file mode 100644 index 00000000..8b36d87a --- /dev/null +++ b/pkgs/logging/CHANGELOG.md @@ -0,0 +1,6 @@ +## 0.9.3 + +* Added optional `LogRecord.zone` field. + +* Record current zone (or user specified zone) when creating new `LogRecord`s. + diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index dc83d848..42344e83 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -138,16 +138,26 @@ class Logger { * If [message] is a [Function], it will be lazy evaluated. Additionally, if * [message] or its evaluated value is not a [String], then 'toString()' will * be called on it and the result will be logged. + * + * The log record will contain a field for the zone in which this call was + * made. + * This can be advantagous if a log listener wants to handle records of + * 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]) { + 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(); // If message is still not a String, call toString(). if (message is! String) message = message.toString(); + // 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); + stackTrace, zone); if (hierarchicalLoggingEnabled) { var target = this; @@ -314,8 +324,12 @@ class LogRecord { /** Associated stackTrace (if any) when recording errors messages. */ final StackTrace stackTrace; + /** 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.stackTrace, + this.zone]) : time = new DateTime.now(), sequenceNumber = LogRecord._nextNumber++; diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 5a0b86fa..3867be53 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.9.2 +version: 0.9.3 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 223498f0..8eb116a1 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -5,6 +5,8 @@ library logging_test; +import 'dart:async'; + import 'package:logging/logging.dart'; import 'package:unittest/unittest.dart'; @@ -150,6 +152,53 @@ main() { expect(shout.stackTrace, isNull); }); + group('zone gets recorded to LogRecord', () { + test('root zone', () { + var root = Logger.root; + + var recordingZone = Zone.current; + var records = new List(); + root.onRecord.listen(records.add); + root.info('hello'); + + expect(records, hasLength(1)); + expect(records.first.zone, equals(recordingZone)); + }); + + test('child zone', () { + var root = Logger.root; + + var recordingZone; + var records = new List(); + root.onRecord.listen(records.add); + + runZoned(() { + recordingZone = Zone.current; + root.info('hello'); + }); + + expect(records, hasLength(1)); + expect(records.first.zone, equals(recordingZone)); + }); + + test('custom zone', () { + var root = Logger.root; + + var recordingZone; + var records = new List(); + root.onRecord.listen(records.add); + + runZoned(() { + recordingZone = Zone.current; + }); + + runZoned(() => root.log(Level.INFO, 'hello', null, null, recordingZone)); + + expect(records, hasLength(1)); + expect(records.first.zone, equals(recordingZone)); + }); + }); + group('mutating levels', () { Logger root = Logger.root; Logger a = new Logger('a'); From e6e65f69c59618c5917bc4425c45398e6ac1b13f Mon Sep 17 00:00:00 2001 From: Oliver Sand Date: Fri, 10 Apr 2015 18:55:00 +0200 Subject: [PATCH 065/163] Allow a greater range of types as a stack trace --- pkgs/logging/CHANGELOG.md | 4 ++++ pkgs/logging/lib/logging.dart | 20 ++++++++++---------- pkgs/logging/pubspec.yaml | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 8b36d87a..353e3b4c 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.0 + +* Change type of `stackTrace` from `StackTrace` to `Object`. + ## 0.9.3 * Added optional `LogRecord.zone` field. diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 42344e83..9eebe3a9 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -147,7 +147,7 @@ class Logger { */ void log(Level logLevel, message, - [Object error, StackTrace stackTrace, Zone zone]) { + [Object error, Object stackTrace, Zone zone]) { if (isLoggable(logLevel)) { // If message is a Function, evaluate it. if (message is Function) message = message(); @@ -172,35 +172,35 @@ class Logger { } /** Log message at level [Level.FINEST]. */ - void finest(message, [Object error, StackTrace stackTrace]) => + void finest(message, [Object error, Object stackTrace]) => log(Level.FINEST, message, error, stackTrace); /** Log message at level [Level.FINER]. */ - void finer(message, [Object error, StackTrace stackTrace]) => + void finer(message, [Object error, Object stackTrace]) => log(Level.FINER, message, error, stackTrace); /** Log message at level [Level.FINE]. */ - void fine(message, [Object error, StackTrace stackTrace]) => + void fine(message, [Object error, Object stackTrace]) => log(Level.FINE, message, error, stackTrace); /** Log message at level [Level.CONFIG]. */ - void config(message, [Object error, StackTrace stackTrace]) => + void config(message, [Object error, Object stackTrace]) => log(Level.CONFIG, message, error, stackTrace); /** Log message at level [Level.INFO]. */ - void info(message, [Object error, StackTrace stackTrace]) => + void info(message, [Object error, Object stackTrace]) => log(Level.INFO, message, error, stackTrace); /** Log message at level [Level.WARNING]. */ - void warning(message, [Object error, StackTrace stackTrace]) => + void warning(message, [Object error, Object stackTrace]) => log(Level.WARNING, message, error, stackTrace); /** Log message at level [Level.SEVERE]. */ - void severe(message, [Object error, StackTrace stackTrace]) => + void severe(message, [Object error, Object stackTrace]) => log(Level.SEVERE, message, error, stackTrace); /** Log message at level [Level.SHOUT]. */ - void shout(message, [Object error, StackTrace stackTrace]) => + void shout(message, [Object error, Object stackTrace]) => log(Level.SHOUT, message, error, stackTrace); Stream _getStream() { @@ -322,7 +322,7 @@ class LogRecord { final Object error; /** Associated stackTrace (if any) when recording errors messages. */ - final StackTrace stackTrace; + final Object stackTrace; /** Zone of the calling code which resulted in this LogRecord. */ final Zone zone; diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 3867be53..2e4c2666 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.9.3 +version: 0.10.0 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces From 77cc905bf98facd0c29e25f411e8503fee5c0943 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 6 May 2015 11:45:14 -0700 Subject: [PATCH 066/163] Revert change to make stackTrace object --- pkgs/logging/CHANGELOG.md | 7 +++++++ pkgs/logging/lib/logging.dart | 20 ++++++++++---------- pkgs/logging/pubspec.yaml | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 353e3b4c..d0723026 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,10 @@ +## 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.dartlang.org/packages/stack_trace + ## 0.10.0 * Change type of `stackTrace` from `StackTrace` to `Object`. diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 9eebe3a9..42344e83 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -147,7 +147,7 @@ class Logger { */ void log(Level logLevel, message, - [Object error, Object stackTrace, Zone zone]) { + [Object error, StackTrace stackTrace, Zone zone]) { if (isLoggable(logLevel)) { // If message is a Function, evaluate it. if (message is Function) message = message(); @@ -172,35 +172,35 @@ class Logger { } /** Log message at level [Level.FINEST]. */ - void finest(message, [Object error, Object stackTrace]) => + void finest(message, [Object error, StackTrace stackTrace]) => log(Level.FINEST, message, error, stackTrace); /** Log message at level [Level.FINER]. */ - void finer(message, [Object error, Object stackTrace]) => + void finer(message, [Object error, StackTrace stackTrace]) => log(Level.FINER, message, error, stackTrace); /** Log message at level [Level.FINE]. */ - void fine(message, [Object error, Object stackTrace]) => + void fine(message, [Object error, StackTrace stackTrace]) => log(Level.FINE, message, error, stackTrace); /** Log message at level [Level.CONFIG]. */ - void config(message, [Object error, Object stackTrace]) => + void config(message, [Object error, StackTrace stackTrace]) => log(Level.CONFIG, message, error, stackTrace); /** Log message at level [Level.INFO]. */ - void info(message, [Object error, Object stackTrace]) => + void info(message, [Object error, StackTrace stackTrace]) => log(Level.INFO, message, error, stackTrace); /** Log message at level [Level.WARNING]. */ - void warning(message, [Object error, Object stackTrace]) => + void warning(message, [Object error, StackTrace stackTrace]) => log(Level.WARNING, message, error, stackTrace); /** Log message at level [Level.SEVERE]. */ - void severe(message, [Object error, Object stackTrace]) => + void severe(message, [Object error, StackTrace stackTrace]) => log(Level.SEVERE, message, error, stackTrace); /** Log message at level [Level.SHOUT]. */ - void shout(message, [Object error, Object stackTrace]) => + void shout(message, [Object error, StackTrace stackTrace]) => log(Level.SHOUT, message, error, stackTrace); Stream _getStream() { @@ -322,7 +322,7 @@ class LogRecord { final Object error; /** Associated stackTrace (if any) when recording errors messages. */ - final Object stackTrace; + final StackTrace stackTrace; /** Zone of the calling code which resulted in this LogRecord. */ final Zone zone; diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 2e4c2666..987068c9 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.10.0 +version: 0.11.0-dev author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces From c6a611887bbace0a2562a8e49e01e39ff141b9c5 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 12 Jan 2015 23:42:19 -0800 Subject: [PATCH 067/163] dartfmt --- pkgs/logging/lib/logging.dart | 38 +++++---- pkgs/logging/test/logging_test.dart | 118 ++++++++++++++++------------ 2 files changed, 87 insertions(+), 69 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 42344e83..76548857 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -21,7 +21,6 @@ bool hierarchicalLoggingEnabled = false; */ 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 @@ class Logger { return new Logger._internal(thisName, parent, new Map()); } - Logger._internal(this.name, this.parent, Map children) : - this._children = children, - this.children = new UnmodifiableMapView(children) { + Logger._internal(this.name, this.parent, Map children) + : this._children = children, + this.children = new UnmodifiableMapView(children) { if (parent != null) parent._children[name] = this; } @@ -145,9 +144,8 @@ class Logger { * 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 @@ class Logger { // 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 @@ class Logger { static final Map _loggers = {}; } - /** Handler callback to process log entries as they are added to a [Logger]. */ typedef void LoggerHandler(LogRecord); @@ -244,7 +241,6 @@ typedef void LoggerHandler(LogRecord); * [Level.OFF]. */ class Level implements Comparable { - final String name; /** @@ -285,8 +281,18 @@ class Level implements Comparable { /** Key for extra debugging loudness ([value] = 1200). */ static const Level SHOUT = const Level('SHOUT', 1200); - static const List LEVELS = const - [ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, SHOUT, OFF]; + static const List 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 @@ class Level implements Comparable { String toString() => name; } - /** * A log entry representation used to propagate information from [Logger] to * individual [Handler]s. @@ -327,9 +332,8 @@ class LogRecord { /** 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/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 8eb116a1..2162254c 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/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 @@ main() { 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 @@ main() { 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 @@ main() { 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 @@ main() { }); 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 @@ main() { 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 @@ main() { 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 @@ main() { 'INFO: 5', 'WARNING: 6', 'SEVERE: 7', - 'SHOUT: 8'])); + 'SHOUT: 8' + ])); }); test('logging methods store exception', () { @@ -360,7 +374,8 @@ main() { 'INFO: 5 e', 'WARNING: 6 f', 'SEVERE: 7 g', - 'SHOUT: 8 h'])); + 'SHOUT: 8 h' + ])); }); test('message logging - no hierarchy', () { @@ -392,16 +407,17 @@ main() { 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 @@ main() { 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 @@ main() { 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 @@ main() { 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',])); }); }); } From 36292c72f65730b12bbfb2889c2223655457fccf Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 12 Jan 2015 23:42:37 -0800 Subject: [PATCH 068/163] tweaked readme example --- pkgs/logging/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index f4781a7a..de5b8c5e 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -43,7 +43,7 @@ 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("-")); +log.fine(() => [1, 2, 3, 4, 5].map((e) => e * 4).join("-")); ``` See the [Logger] class for the different logging methods. From 972f7cc3a91a776f6f2afa40fee5ca61a44b26ef Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 6 May 2015 11:49:09 -0700 Subject: [PATCH 069/163] move to test pkg --- pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 987068c9..3a9e1353 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -9,4 +9,4 @@ homepage: https://github.com/dart-lang/logging environment: sdk: '>=1.5.0 <2.0.0' dev_dependencies: - unittest: '>=0.9.0 <0.12.0' + test: '>=0.12.0 <0.13.0' diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 2162254c..94696d8d 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -7,9 +7,9 @@ library logging_test; import 'dart:async'; import 'package:logging/logging.dart'; -import 'package:unittest/unittest.dart'; +import 'package:test/test.dart'; -main() { +void main() { test('level comparison is a valid comparator', () { var level1 = const Level('NOT_REAL1', 253); expect(level1 == level1, isTrue); From d8ac9500a9434de0f0acfa57f40c2406e990a3be Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 6 May 2015 11:50:08 -0700 Subject: [PATCH 070/163] ship 0.11.0 --- pkgs/logging/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 3a9e1353..2b7d1307 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.11.0-dev +version: 0.11.0 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces From f060bc82e9ac9fe28f78477aa3e2cccf8236f771 Mon Sep 17 00:00:00 2001 From: Sigmund Cherem Date: Thu, 7 May 2015 15:36:49 -0700 Subject: [PATCH 071/163] Add option to automatically record stack trace in logging (fixes dart-lang/logging#2) R=jmesserly@google.com Review URL: https://codereview.chromium.org//1132533003 --- pkgs/logging/CHANGELOG.md | 5 +++ pkgs/logging/lib/logging.dart | 16 +++++++-- pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 50 +++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index d0723026..b0b759e8 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,8 @@ +## 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`. diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 76548857..f108ed3b 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -15,6 +15,12 @@ import 'dart:collection'; */ bool hierarchicalLoggingEnabled = false; +/** + * Automatically record stack traces for any message of this level or above. + * Because this is expensive, this is off by default. + */ +Level recordStackTraceAtLevel = Level.OFF; + /** * Level for the root-logger. This will be the level of all loggers if * [hierarchicalLoggingEnabled] is false. @@ -147,11 +153,15 @@ class Logger { 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(); - // If message is still not a String, call toString(). if (message is! String) message = message.toString(); - // Only record the current zone if it was not given. + if (stackTrace == null && logLevel >= recordStackTraceAtLevel) { + try { + throw "autogenerated stack trace for $logLevel $message"; + } catch (e, t) { + stackTrace = t; + } + } if (zone == null) zone = Zone.current; var record = diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 2b7d1307..1236b30d 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.11.0 +version: 0.11.1 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 94696d8d..e27ee2f3 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -520,4 +520,54 @@ void main() { equals(['INFO: 5', 'INFO: false', 'INFO: [1, 2, 3]', 'INFO: 10',])); }); }); + + group('recordStackTraceAtLevel', () { + var root = Logger.root; + tearDown(() { + recordStackTraceAtLevel = Level.OFF; + root.clearListeners(); + }); + + test('no stack trace by default', () { + var records = new List(); + root.onRecord.listen(records.add); + root.severe('hello'); + root.warning('hello'); + root.info('hello'); + expect(records, hasLength(3)); + expect(records[0].stackTrace, isNull); + expect(records[1].stackTrace, isNull); + expect(records[2].stackTrace, isNull); + }); + + test('trace recorded only on requested levels', () { + var records = new List(); + recordStackTraceAtLevel = Level.WARNING; + root.onRecord.listen(records.add); + root.severe('hello'); + root.warning('hello'); + root.info('hello'); + expect(records, hasLength(3)); + expect(records[0].stackTrace, isNotNull); + expect(records[1].stackTrace, isNotNull); + expect(records[2].stackTrace, isNull); + }); + + test('provided trace is used if given', () { + var trace; + try { + throw 'trace'; + } catch(e, t) { + trace = t; + } + var records = new List(); + recordStackTraceAtLevel = Level.WARNING; + root.onRecord.listen(records.add); + root.severe('hello'); + root.warning('hello', 'a', trace); + expect(records, hasLength(2)); + expect(records[0].stackTrace, isNot(equals(trace))); + expect(records[1].stackTrace, trace); + }); + }); } From 083d3d20f224041cb744314ceeb923d93de5fafe Mon Sep 17 00:00:00 2001 From: Olivier Chafik Date: Wed, 1 Jul 2015 16:08:15 +0100 Subject: [PATCH 072/163] Improve Logger.root (static final instead of getter that looks the cached instance up through the factory constructor) (note: static fields are lazy anyway) --- pkgs/logging/lib/logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index f108ed3b..c8417fc1 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -229,7 +229,7 @@ class Logger { } /** Top-level root [Logger]. */ - static Logger get root => new Logger(''); + static final Logger root = new Logger(''); /** All [Logger]s in the system. */ static final Map _loggers = {}; From 85d8c60d0e98c87424b761fbfc7bc294c780518e Mon Sep 17 00:00:00 2001 From: Sigmund Cherem Date: Wed, 19 Aug 2015 12:39:56 -0700 Subject: [PATCH 073/163] Also generate error when autogenerating stack traces (fix dart-lang/logging#25) R=jakemac@google.com Review URL: https://codereview.chromium.org//1284983004 . --- pkgs/logging/CHANGELOG.md | 4 ++++ pkgs/logging/lib/logging.dart | 1 + pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 13 +++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index b0b759e8..d04354d5 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 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 diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index c8417fc1..f1641dca 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -160,6 +160,7 @@ class Logger { throw "autogenerated stack trace for $logLevel $message"; } catch (e, t) { stackTrace = t; + if (error == null) error = e; } } if (zone == null) zone = Zone.current; diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 1236b30d..2206dbed 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.11.1 +version: 0.11.1+1 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index e27ee2f3..60017b37 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -569,5 +569,18 @@ void main() { expect(records[0].stackTrace, isNot(equals(trace))); expect(records[1].stackTrace, trace); }); + + test('error also generated when generating a trace', () { + var records = new List(); + recordStackTraceAtLevel = Level.WARNING; + root.onRecord.listen(records.add); + root.severe('hello'); + root.warning('hello'); + root.info('hello'); + expect(records, hasLength(3)); + expect(records[0].error, isNotNull); + expect(records[1].error, isNotNull); + expect(records[2].error, isNull); + }); }); } From a7686ff1c1b93019b59bcc17bebcbb26f5931c4b Mon Sep 17 00:00:00 2001 From: Anton Astashov Date: Wed, 30 Sep 2015 17:46:11 -0500 Subject: [PATCH 074/163] Add Logger.detached factory Sometimes you just don't need to add a logger, which will be a singleton and part of the global loggers tree. So, just a logger, which will be garbage collected, and its onRecord.listen won't subscribe to the root one. Right now, there is theoretical possibility for that, but a constructor for that is private. Added Logger.detached factory, which is doing exactly this. --- pkgs/logging/AUTHORS | 1 + pkgs/logging/lib/logging.dart | 12 ++++++++++++ pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 22 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pkgs/logging/AUTHORS b/pkgs/logging/AUTHORS index 06177657..630ab0e7 100644 --- a/pkgs/logging/AUTHORS +++ b/pkgs/logging/AUTHORS @@ -7,3 +7,4 @@ # Organization # Google Inc. <*@google.com> +Anton Astashov diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index f1641dca..1d835fcf 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -61,6 +61,18 @@ class Logger { return _loggers.putIfAbsent(name, () => new Logger._named(name)); } + /// Creates a new detached [Logger]. + /// + /// Returns a new [Logger] instance (unlike [new Logger], which returns a + /// [Logger] singleton), which doesn't have any parent or children, + /// and it's not a part of the global hierarchial loggers structure. + /// + /// It can be useful when you just need a local short-living logger, + /// which you'd like to be garbage-collected later. + factory Logger.detached(String name) { + return new Logger._internal(name, null, new Map()); + } + factory Logger._named(String name) { if (name.startsWith('.')) { throw new ArgumentError("name shouldn't start with a '.'"); diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 2206dbed..2bbbe94e 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.11.1+1 +version: 0.11.2 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 60017b37..2f5bf60e 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -206,6 +206,28 @@ void main() { }); }); + group('detached loggers', () { + test("create new instances of Logger", () { + Logger a1 = new Logger.detached("a"); + Logger a2 = new Logger.detached("a"); + Logger a = new Logger("a"); + + expect(a1, isNot(a2)); + expect(a1, isNot(a)); + expect(a2, isNot(a)); + }); + + test("parent is null", () { + Logger a = new Logger.detached("a"); + expect(a.parent, null); + }); + + test("children is empty", () { + Logger a = new Logger.detached("a"); + expect(a.children, {}); + }); + }); + group('mutating levels', () { Logger root = Logger.root; Logger a = new Logger('a'); From 1c327a69092a3a486dead5e155b26320bbc1f4d2 Mon Sep 17 00:00:00 2001 From: Sigmund Cherem Date: Thu, 1 Oct 2015 12:37:00 -0700 Subject: [PATCH 075/163] Add changelog entry --- pkgs/logging/CHANGELOG.md | 5 +++++ pkgs/logging/lib/logging.dart | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index d04354d5..32204e71 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.11.2 + +* Added Logger.detached - a convinience 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. diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 1d835fcf..493d8599 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -63,7 +63,7 @@ class Logger { /// Creates a new detached [Logger]. /// - /// Returns a new [Logger] instance (unlike [new Logger], which returns a + /// Returns a new [Logger] instance (unlike `new Logger`, which returns a /// [Logger] singleton), which doesn't have any parent or children, /// and it's not a part of the global hierarchial loggers structure. /// From b7807a906e99cf3e97b82a5c90364e5778dad3d4 Mon Sep 17 00:00:00 2001 From: Jason Aguilon Date: Mon, 18 Apr 2016 11:00:23 -0600 Subject: [PATCH 076/163] save non-string object on LogRecord (dart-lang/logging#28) Save non-string object on `LogRecord` so that a handler can access the original object instead of just its `toString()` --- pkgs/logging/CHANGELOG.md | 10 +++++++++- pkgs/logging/lib/logging.dart | 21 +++++++++++++++------ pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 15 +++++++++++++-- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 32204e71..953c7635 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,6 +1,14 @@ +## 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 convinience factory to obtain a logger that is not +* Added Logger.detached - a convenience factory to obtain a logger that is not attached to this library's logger hierarchy. ## 0.11.1+1 diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 493d8599..48663294 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -154,19 +154,24 @@ class Logger { * * If [message] is a [Function], it will be lazy evaluated. Additionally, if * [message] or its evaluated value is not a [String], then 'toString()' will - * be called on it and the result will be logged. + * be called on the object and the result will be logged. The log record will + * contain a field holding the original object. * - * The log record will contain a field for the zone in which this call was - * made. + * The log record will also contain a field for the zone in which this call + * was made. * This can be advantagous if a log listener wants to handle records of * 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]) { + Object object; if (isLoggable(logLevel)) { if (message is Function) message = message(); - if (message is! String) message = message.toString(); + if (message is! String) { + object = message; + message = message.toString(); + } if (stackTrace == null && logLevel >= recordStackTraceAtLevel) { try { throw "autogenerated stack trace for $logLevel $message"; @@ -178,7 +183,8 @@ class Logger { if (zone == null) zone = Zone.current; var record = - new LogRecord(logLevel, message, fullName, error, stackTrace, zone); + new LogRecord(logLevel, message, fullName, error, stackTrace, zone, + object); if (hierarchicalLoggingEnabled) { var target = this; @@ -335,6 +341,9 @@ class LogRecord { final Level level; final String message; + /** Non-string message passed to Logger. */ + final Object object; + /** Logger where this record is stored. */ final String loggerName; @@ -356,7 +365,7 @@ class LogRecord { final Zone zone; LogRecord(this.level, this.message, this.loggerName, - [this.error, this.stackTrace, this.zone]) + [this.error, this.stackTrace, this.zone, this.object]) : time = new DateTime.now(), sequenceNumber = LogRecord._nextNumber++; diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 2bbbe94e..91d2cc71 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.11.2 +version: 0.11.3 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 2f5bf60e..863650bd 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -529,17 +529,28 @@ void main() { test('message logging - calls toString', () { root.level = Level.INFO; var messages = []; + var objects = []; + var object = new Object(); root.onRecord.listen((record) { messages.add('${record.level}: ${record.message}'); + objects.add(record.object); }); root.info(5); root.info(false); root.info([1, 2, 3]); root.info(() => 10); + root.info(object); - 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', + "INFO: Instance of 'Object'" + ])); + + expect(objects, [5, false, [1, 2, 3], 10, object]); }); }); From 22967da2f5cb2fcc274dc3826891e1a7f520b407 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 18 Jul 2016 10:40:59 -0700 Subject: [PATCH 077/163] dartfmt --- pkgs/logging/lib/logging.dart | 5 +- pkgs/logging/test/logging_test.dart | 180 +++++++++++++++------------- 2 files changed, 102 insertions(+), 83 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 48663294..b816e89d 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -182,9 +182,8 @@ class Logger { } if (zone == null) zone = Zone.current; - var record = - new LogRecord(logLevel, message, fullName, error, stackTrace, zone, - object); + var record = new LogRecord( + logLevel, message, fullName, error, stackTrace, zone, object); if (hierarchicalLoggingEnabled) { var target = this; diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 863650bd..b73fdcc9 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -344,16 +344,18 @@ void main() { root.severe('7'); root.shout('8'); - expect(rootMessages, equals([ - 'FINEST: 1', - 'FINER: 2', - 'FINE: 3', - 'CONFIG: 4', - 'INFO: 5', - 'WARNING: 6', - 'SEVERE: 7', - 'SHOUT: 8' - ])); + expect( + rootMessages, + equals([ + 'FINEST: 1', + 'FINER: 2', + 'FINE: 3', + 'CONFIG: 4', + 'INFO: 5', + 'WARNING: 6', + 'SEVERE: 7', + 'SHOUT: 8' + ])); }); test('logging methods store exception', () { @@ -380,24 +382,26 @@ void main() { root.severe('7', 'g'); root.shout('8', 'h'); - expect(rootMessages, equals([ - 'FINEST: 1 null', - 'FINER: 2 null', - 'FINE: 3 null', - 'CONFIG: 4 null', - 'INFO: 5 null', - 'WARNING: 6 null', - 'SEVERE: 7 null', - 'SHOUT: 8 null', - 'FINEST: 1 a', - 'FINER: 2 b', - 'FINE: 3 [c]', - 'CONFIG: 4 d', - 'INFO: 5 e', - 'WARNING: 6 f', - 'SEVERE: 7 g', - 'SHOUT: 8 h' - ])); + expect( + rootMessages, + equals([ + 'FINEST: 1 null', + 'FINER: 2 null', + 'FINE: 3 null', + 'CONFIG: 4 null', + 'INFO: 5 null', + 'WARNING: 6 null', + 'SEVERE: 7 null', + 'SHOUT: 8 null', + 'FINEST: 1 a', + 'FINER: 2 b', + 'FINE: 3 [c]', + 'CONFIG: 4 d', + 'INFO: 5 e', + 'WARNING: 6 f', + 'SEVERE: 7 g', + 'SHOUT: 8 h' + ])); }); test('message logging - no hierarchy', () { @@ -428,18 +432,20 @@ void main() { c.warning('9'); 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' - ])); + 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' + ])); // no hierarchy means we all hear the same thing. expect(aMessages, equals(rootMessages)); @@ -477,36 +483,42 @@ void main() { c.warning('9'); 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' - ])); - - 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' - ])); - - expect(cMessages, equals([ - // 1 - 7 are lower in the hierarchy - // 'FINE: 8' is not loggable - 'WARNING: 9', - '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' + ])); + + 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' + ])); + + expect( + cMessages, + equals([ + // 1 - 7 are lower in the hierarchy + // 'FINE: 8' is not loggable + 'WARNING: 9', + 'SHOUT: 10' + ])); }); test('message logging - lazy functions', () { @@ -542,15 +554,23 @@ void main() { root.info(() => 10); root.info(object); - expect(messages, equals([ - 'INFO: 5', - 'INFO: false', - 'INFO: [1, 2, 3]', - 'INFO: 10', - "INFO: Instance of 'Object'" - ])); - - expect(objects, [5, false, [1, 2, 3], 10, object]); + expect( + messages, + equals([ + 'INFO: 5', + 'INFO: false', + 'INFO: [1, 2, 3]', + 'INFO: 10', + "INFO: Instance of 'Object'" + ])); + + expect(objects, [ + 5, + false, + [1, 2, 3], + 10, + object + ]); }); }); @@ -590,7 +610,7 @@ void main() { var trace; try { throw 'trace'; - } catch(e, t) { + } catch (e, t) { trace = t; } var records = new List(); From 668275c5e47377fb8912d5c7e207d1dbd42bcf93 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 18 Jul 2016 10:42:19 -0700 Subject: [PATCH 078/163] cleanup .gitignore --- pkgs/logging/.gitignore | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/pkgs/logging/.gitignore b/pkgs/logging/.gitignore index 388eff0b..aac1f4fe 100644 --- a/pkgs/logging/.gitignore +++ b/pkgs/logging/.gitignore @@ -1,14 +1,4 @@ -# Don’t commit the following directories created by pub. -.buildlog -.pub/ -build/ +.packages +.pub packages - -# Or the files created by dart2js. -*.dart.js -*.js_ -*.js.deps -*.js.map - -# Include when developing application packages. -pubspec.lock \ No newline at end of file +pubspec.lock From beb44760f617cc64b8e31e00f4aeb885a9be4edb Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Fri, 15 Jul 2016 12:44:20 -0700 Subject: [PATCH 079/163] Fixing some doc comments --- pkgs/logging/CHANGELOG.md | 4 ++ pkgs/logging/lib/logging.dart | 78 +++++++++++++++++------------------ pkgs/logging/pubspec.yaml | 2 +- 3 files changed, 44 insertions(+), 40 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 953c7635..187dc0f1 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.3+1 + +* Fixed several documentation comments. + ## 0.11.3 * Added optional `LogRecord.object` field. diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index b816e89d..9a7e5317 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -9,27 +9,27 @@ library logging; import 'dart:async'; import 'dart:collection'; -/** - * Whether to allow fine-grain logging and configuration of loggers in a - * hierarchy. When false, all logging is merged in the root logger. - */ +/// Whether to allow fine-grain logging and configuration of loggers in a +/// hierarchy. +/// +/// When false, all logging is merged in the root logger. bool hierarchicalLoggingEnabled = false; -/** - * Automatically record stack traces for any message of this level or above. - * Because this is expensive, this is off by default. - */ +/// Automatically record stack traces for any message of this level or above. +/// +/// Because this is expensive, this is off by default. Level recordStackTraceAtLevel = Level.OFF; -/** - * Level for the root-logger. This will be the level of all loggers if - * [hierarchicalLoggingEnabled] is false. - */ +/// Level for the root-logger. +/// +/// This will be the level of all loggers if [hierarchicalLoggingEnabled] is +/// false. Level _rootLevel = Level.INFO; /** - * Use a [Logger] to log debug messages. [Logger]s are named using a - * hierarchical dot-separated name convention. + * Use a [Logger] to log debug messages. + * + * [Logger]s are named using a hierarchical dot-separated name convention. */ class Logger { /** Simple name of this logger. */ @@ -65,7 +65,7 @@ class Logger { /// /// Returns a new [Logger] instance (unlike `new Logger`, which returns a /// [Logger] singleton), which doesn't have any parent or children, - /// and it's not a part of the global hierarchial loggers structure. + /// and is not a part of the global hierarchical loggers structure. /// /// It can be useful when you just need a local short-living logger, /// which you'd like to be garbage-collected later. @@ -123,11 +123,13 @@ class Logger { } } - /** - * Returns an stream of messages added to this [Logger]. You can listen for - * messages using the standard stream APIs, for instance: - * logger.onRecord.listen((record) { ... }); - */ + /// Returns a stream of messages added to this [Logger]. + /// + /// You can listen for messages using the standard stream APIs, for instance: + /// + /// ```dart + /// logger.onRecord.listen((record) { ... }); + /// ``` Stream get onRecord => _getStream(); void clearListeners() { @@ -144,25 +146,23 @@ class Logger { /** Whether a message for [value]'s level is loggable in this logger. */ bool isLoggable(Level value) => (value >= level); - /** - * Adds a log record for a [message] at a particular [logLevel] if - * `isLoggable(logLevel)` is true. - * - * Use this method to create log entries for user-defined levels. To record a - * message at a predefined level (e.g. [Level.INFO], [Level.WARNING], etc) you - * can use their specialized methods instead (e.g. [info], [warning], etc). - * - * If [message] is a [Function], it will be lazy evaluated. Additionally, if - * [message] or its evaluated value is not a [String], then 'toString()' will - * be called on the object and the result will be logged. The log record will - * contain a field holding the original object. - * - * The log record will also contain a field for the zone in which this call - * was made. - * This can be advantagous if a log listener wants to handle records of - * different zones differently (e.g. group log records by http-request if each - * http-request handler runs in it's own zone). - */ + /// Adds a log record for a [message] at a particular [logLevel] if + /// `isLoggable(logLevel)` is true. + /// + /// Use this method to create log entries for user-defined levels. To record a + /// message at a predefined level (e.g. [Level.INFO], [Level.WARNING], etc) + /// you can use their specialized methods instead (e.g. [info], [warning], + /// etc). + /// + /// If [message] is a [Function], it will be lazy evaluated. Additionally, if + /// [message] or its evaluated value is not a [String], then 'toString()' will + /// be called on the object and the result will be logged. The log record will + /// contain a field holding the original object. + /// + /// The log record will also contain a field for the zone in which this call + /// was made. This can be advantageous if a log listener wants to handler + /// records of 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]) { Object object; diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 91d2cc71..97eec7a7 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.11.3 +version: 0.11.3+1 author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces From 0d41cdca9ca087b4f44063cd56dd05504235ac5d Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 24 Jan 2017 13:25:54 -0800 Subject: [PATCH 080/163] Use correct config for pkg/test on bots --- pkgs/logging/.status | 15 --------------- pkgs/logging/.test_config | 3 +++ 2 files changed, 3 insertions(+), 15 deletions(-) delete mode 100644 pkgs/logging/.status create mode 100644 pkgs/logging/.test_config diff --git a/pkgs/logging/.status b/pkgs/logging/.status deleted file mode 100644 index ff095a2f..00000000 --- a/pkgs/logging/.status +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file -# 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. - -# Skip non-test files ending with "_test". -packages/*: Skip -*/packages/*: Skip -*/*/packages/*: Skip -*/*/*/packages/*: Skip -*/*/*/*packages/*: Skip -*/*/*/*/*packages/*: Skip - -# Only run tests from the build directory, since we don't care about the -# difference between transformed an untransformed code. -test/*: Skip diff --git a/pkgs/logging/.test_config b/pkgs/logging/.test_config new file mode 100644 index 00000000..412fc5c5 --- /dev/null +++ b/pkgs/logging/.test_config @@ -0,0 +1,3 @@ +{ + "test_package": true +} \ No newline at end of file From a617f8576d4148f076a036d3520628606d1b7c0b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 23 Oct 2017 14:23:38 -0700 Subject: [PATCH 081/163] Enable travis, add analysis_options, other cleanup (dart-lang/logging#35) * Fix strong-mode issues * dartfmt * Switch to triple-slash, @override, single quotes * Enable Travis-CI --- pkgs/logging/.travis.yml | 29 +++++ pkgs/logging/analysis_options.yaml | 38 +++++++ pkgs/logging/lib/logging.dart | 169 ++++++++++++++-------------- pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 54 ++++----- 5 files changed, 179 insertions(+), 113 deletions(-) create mode 100644 pkgs/logging/.travis.yml create mode 100644 pkgs/logging/analysis_options.yaml diff --git a/pkgs/logging/.travis.yml b/pkgs/logging/.travis.yml new file mode 100644 index 00000000..1e1c46c6 --- /dev/null +++ b/pkgs/logging/.travis.yml @@ -0,0 +1,29 @@ +language: dart +sudo: false +dart: + - dev + - stable + +dart_task: + - test: --platform vm + - test: --platform firefox + - test: --platform chrome + - test: --platform dartium + install_dartium: true + +matrix: + include: + - dart: dev + dart_task: dartfmt + - dart: dev + dart_task: dartanalyzer + - dart: stable + dart_task: dartanalyzer + +# Only building master means that we don't run two builds for each pull request. +branches: + only: [master] + +cache: + directories: + - $HOME/.pub-cache diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml new file mode 100644 index 00000000..848b33ff --- /dev/null +++ b/pkgs/logging/analysis_options.yaml @@ -0,0 +1,38 @@ +analyzer: + strong-mode: + implicit-casts: false + errors: + unused_element: error + unused_import: error + unused_local_variable: error + dead_code: error +linter: + rules: + - annotate_overrides + - avoid_empty_else + - avoid_init_to_null + - avoid_return_types_on_setters + - await_only_futures + - camel_case_types + - comment_references + - control_flow_in_finally + - directives_ordering + - empty_catches + - empty_constructor_bodies + - empty_statements + - hash_and_equals + - implementation_imports + - library_names + - library_prefixes + - non_constant_identifier_names + - only_throw_errors + - prefer_final_fields + - prefer_is_not_empty + - prefer_single_quotes + - slash_for_doc_comments + - test_types_in_equals + - test_types_in_equals + - throw_in_finally + - type_init_formals + - unrelated_type_equality_checks + - valid_regexps diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 9a7e5317..e278d765 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -2,8 +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; import 'dart:async'; @@ -26,37 +24,33 @@ Level recordStackTraceAtLevel = Level.OFF; /// false. Level _rootLevel = Level.INFO; -/** - * Use a [Logger] to log debug messages. - * - * [Logger]s are named using a hierarchical dot-separated name convention. - */ +/// Use a [Logger] to log debug messages. +/// +/// [Logger]s are named using a hierarchical dot-separated name convention. class Logger { - /** Simple name of this logger. */ + /// Simple name of this logger. final String name; - /** The full name of this logger, which includes the parent's full name. */ + /// The full name of this logger, which includes the parent's full name. String get fullName => (parent == null || parent.name == '') ? name : '${parent.fullName}.$name'; - /** Parent of this logger in the hierarchy of loggers. */ + /// Parent of this logger in the hierarchy of loggers. final Logger parent; - /** Logging [Level] used for entries generated on this logger. */ + /// Logging [Level] used for entries generated on this logger. Level _level; final Map _children; - /** Children in the hierarchy of loggers, indexed by their simple names. */ + /// Children in the hierarchy of loggers, indexed by their simple names. final Map children; - /** Controller used to notify when log entries are added to this logger. */ + /// Controller used to notify when log entries are added to this logger. StreamController _controller; - /** - * Singleton constructor. Calling `new Logger(name)` will return the same - * actual instance whenever it is called with the same string name. - */ + /// Singleton constructor. Calling `new Logger(name)` will return the same + /// actual instance whenever it is called with the same string name. factory Logger(String name) { return _loggers.putIfAbsent(name, () => new Logger._named(name)); } @@ -79,7 +73,7 @@ class Logger { } // Split hierarchical names (separated with '.'). int dot = name.lastIndexOf('.'); - Logger parent = null; + Logger parent; String thisName; if (dot == -1) { if (name != '') parent = new Logger(''); @@ -97,10 +91,8 @@ class Logger { if (parent != null) parent._children[name] = this; } - /** - * Effective level considering the levels established in this logger's parents - * (when [hierarchicalLoggingEnabled] is true). - */ + /// Effective level considering the levels established in this logger's + /// parents (when [hierarchicalLoggingEnabled] is true). Level get level { if (hierarchicalLoggingEnabled) { if (_level != null) return _level; @@ -109,8 +101,8 @@ class Logger { return _rootLevel; } - /** Override the level for this particular [Logger] and its children. */ - void set level(Level value) { + /// Override the level for this particular [Logger] and its children. + set level(Level value) { if (hierarchicalLoggingEnabled && parent != null) { _level = value; } else { @@ -143,7 +135,7 @@ class Logger { } } - /** Whether a message for [value]'s level is loggable in this logger. */ + /// Whether a message for [value]'s level is loggable in this logger. bool isLoggable(Level value) => (value >= level); /// Adds a log record for a [message] at a particular [logLevel] if @@ -167,23 +159,26 @@ class Logger { [Object error, StackTrace stackTrace, Zone zone]) { Object object; if (isLoggable(logLevel)) { - if (message is Function) message = message(); - if (message is! String) { + if (message is Function) { + message = message(); + } + + String msg; + if (message is String) { + msg = message; + } else { + msg = message.toString(); object = message; - message = message.toString(); } + if (stackTrace == null && logLevel >= recordStackTraceAtLevel) { - try { - throw "autogenerated stack trace for $logLevel $message"; - } catch (e, t) { - stackTrace = t; - if (error == null) error = e; - } + stackTrace = StackTrace.current; + error ??= 'autogenerated stack trace for $logLevel $msg'; } if (zone == null) zone = Zone.current; var record = new LogRecord( - logLevel, message, fullName, error, stackTrace, zone, object); + logLevel, msg, fullName, error, stackTrace, zone, object); if (hierarchicalLoggingEnabled) { var target = this; @@ -197,35 +192,35 @@ class Logger { } } - /** Log message at level [Level.FINEST]. */ + /// Log message at level [Level.FINEST]. void finest(message, [Object error, StackTrace stackTrace]) => log(Level.FINEST, message, error, stackTrace); - /** Log message at level [Level.FINER]. */ + /// Log message at level [Level.FINER]. void finer(message, [Object error, StackTrace stackTrace]) => log(Level.FINER, message, error, stackTrace); - /** Log message at level [Level.FINE]. */ + /// Log message at level [Level.FINE]. void fine(message, [Object error, StackTrace stackTrace]) => log(Level.FINE, message, error, stackTrace); - /** Log message at level [Level.CONFIG]. */ + /// Log message at level [Level.CONFIG]. void config(message, [Object error, StackTrace stackTrace]) => log(Level.CONFIG, message, error, stackTrace); - /** Log message at level [Level.INFO]. */ + /// Log message at level [Level.INFO]. void info(message, [Object error, StackTrace stackTrace]) => log(Level.INFO, message, error, stackTrace); - /** Log message at level [Level.WARNING]. */ + /// Log message at level [Level.WARNING]. void warning(message, [Object error, StackTrace stackTrace]) => log(Level.WARNING, message, error, stackTrace); - /** Log message at level [Level.SEVERE]. */ + /// Log message at level [Level.SEVERE]. void severe(message, [Object error, StackTrace stackTrace]) => log(Level.SEVERE, message, error, stackTrace); - /** Log message at level [Level.SHOUT]. */ + /// Log message at level [Level.SHOUT]. void shout(message, [Object error, StackTrace stackTrace]) => log(Level.SHOUT, message, error, stackTrace); @@ -246,67 +241,63 @@ class Logger { } } - /** Top-level root [Logger]. */ + /// Top-level root [Logger]. static final Logger root = new Logger(''); - /** All [Logger]s in the system. */ + /// All [Logger]s in the system. static final Map _loggers = {}; } -/** Handler callback to process log entries as they are added to a [Logger]. */ -typedef void LoggerHandler(LogRecord); - -/** - * [Level]s to control logging output. Logging can be enabled to include all - * levels above certain [Level]. [Level]s are ordered using an integer - * value [Level.value]. The predefined [Level] constants below are sorted as - * follows (in descending order): [Level.SHOUT], [Level.SEVERE], - * [Level.WARNING], [Level.INFO], [Level.CONFIG], [Level.FINE], [Level.FINER], - * [Level.FINEST], and [Level.ALL]. - * - * We recommend using one of the predefined logging levels. If you define your - * own level, make sure you use a value between those used in [Level.ALL] and - * [Level.OFF]. - */ +/// Handler callback to process log entries as they are added to a [Logger]. +typedef void LoggerHandler(LogRecord record); + +/// [Level]s to control logging output. Logging can be enabled to include all +/// levels above certain [Level]. [Level]s are ordered using an integer +/// value [Level.value]. The predefined [Level] constants below are sorted as +/// follows (in descending order): [Level.SHOUT], [Level.SEVERE], +/// [Level.WARNING], [Level.INFO], [Level.CONFIG], [Level.FINE], [Level.FINER], +/// [Level.FINEST], and [Level.ALL]. +/// +/// We recommend using one of the predefined logging levels. If you define your +/// own level, make sure you use a value between those used in [Level.ALL] and +/// [Level.OFF]. class Level implements Comparable { final String name; - /** - * Unique value for this level. Used to order levels, so filtering can exclude - * messages whose level is under certain value. - */ + /// Unique value for this level. Used to order levels, so filtering can + /// exclude messages whose level is under certain value. final int value; const Level(this.name, this.value); - /** Special key to turn on logging for all levels ([value] = 0). */ + /// Special key to turn on logging for all levels ([value] = 0). static const Level ALL = const Level('ALL', 0); - /** Special key to turn off all logging ([value] = 2000). */ + /// Special key to turn off all logging ([value] = 2000). static const Level OFF = const Level('OFF', 2000); - /** Key for highly detailed tracing ([value] = 300). */ + /// Key for highly detailed tracing ([value] = 300). static const Level FINEST = const Level('FINEST', 300); - /** Key for fairly detailed tracing ([value] = 400). */ + /// Key for fairly detailed tracing ([value] = 400). static const Level FINER = const Level('FINER', 400); - /** Key for tracing information ([value] = 500). */ + /// Key for tracing information ([value] = 500). static const Level FINE = const Level('FINE', 500); - /** Key for static configuration messages ([value] = 700). */ + /// Key for static configuration messages ([value] = 700). static const Level CONFIG = const Level('CONFIG', 700); - /** Key for informational messages ([value] = 800). */ + /// Key for informational messages ([value] = 800). static const Level INFO = const Level('INFO', 800); - /** Key for potential problems ([value] = 900). */ + /// Key for potential problems ([value] = 900). static const Level WARNING = const Level('WARNING', 900); - /** Key for serious failures ([value] = 1000). */ + /// Key for serious failures ([value] = 1000). static const Level SEVERE = const Level('SEVERE', 1000); - /** Key for extra debugging loudness ([value] = 1200). */ + /// Key for extra debugging loudness ([value] = 1200). static const Level SHOUT = const Level('SHOUT', 1200); static const List LEVELS = const [ @@ -322,45 +313,50 @@ class Level implements Comparable { OFF ]; - bool operator ==(other) => other is Level && value == other.value; + @override + bool operator ==(Object other) => other is Level && value == other.value; bool operator <(Level other) => value < other.value; bool operator <=(Level other) => value <= other.value; bool operator >(Level other) => value > other.value; bool operator >=(Level other) => value >= other.value; + + @override int compareTo(Level other) => value - other.value; + + @override int get hashCode => value; + + @override String toString() => name; } -/** - * A log entry representation used to propagate information from [Logger] to - * individual [Handler]s. - */ +/// A log entry representation used to propagate information from [Logger] to +/// individual handlers. class LogRecord { final Level level; final String message; - /** Non-string message passed to Logger. */ + /// Non-string message passed to Logger. final Object object; - /** Logger where this record is stored. */ + /// Logger where this record is stored. final String loggerName; - /** Time when this record was created. */ + /// Time when this record was created. final DateTime time; - /** Unique sequence number greater than all log records created before it. */ + /// Unique sequence number greater than all log records created before it. final int sequenceNumber; static int _nextNumber = 0; - /** Associated error (if any) when recording errors messages. */ + /// Associated error (if any) when recording errors messages. final Object error; - /** Associated stackTrace (if any) when recording errors messages. */ + /// Associated stackTrace (if any) when recording errors messages. final StackTrace stackTrace; - /** Zone of the calling code which resulted in this LogRecord. */ + /// Zone of the calling code which resulted in this LogRecord. final Zone zone; LogRecord(this.level, this.message, this.loggerName, @@ -368,5 +364,6 @@ class LogRecord { : time = new DateTime.now(), sequenceNumber = LogRecord._nextNumber++; + @override String toString() => '[${level.name}] $loggerName: $message'; } diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 97eec7a7..3dc84244 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.11.3+1 +version: 0.11.4-dev author: Dart Team description: > Provides APIs for debugging and error logging. This library introduces diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index b73fdcc9..c8543449 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -191,7 +191,7 @@ void main() { test('custom zone', () { var root = Logger.root; - var recordingZone; + Zone recordingZone; var records = new List(); root.onRecord.listen(records.add); @@ -207,23 +207,23 @@ void main() { }); group('detached loggers', () { - test("create new instances of Logger", () { - Logger a1 = new Logger.detached("a"); - Logger a2 = new Logger.detached("a"); - Logger a = new Logger("a"); + test('create new instances of Logger', () { + Logger a1 = new Logger.detached('a'); + Logger a2 = new Logger.detached('a'); + Logger a = new Logger('a'); expect(a1, isNot(a2)); expect(a1, isNot(a)); expect(a2, isNot(a)); }); - test("parent is null", () { - Logger a = new Logger.detached("a"); + test('parent is null', () { + Logger a = new Logger.detached('a'); expect(a.parent, null); }); - test("children is empty", () { - Logger a = new Logger.detached("a"); + test('children is empty', () { + Logger a = new Logger.detached('a'); expect(a.children, {}); }); }); @@ -304,27 +304,29 @@ void main() { test('add/remove handlers - no hierarchy', () { int calls = 0; - var handler = (_) { + void handler(_) { calls++; - }; + } + final sub = c.onRecord.listen(handler); - root.info("foo"); - root.info("foo"); + root.info('foo'); + root.info('foo'); expect(calls, equals(2)); sub.cancel(); - root.info("foo"); + root.info('foo'); expect(calls, equals(2)); }); test('add/remove handlers - with hierarchy', () { hierarchicalLoggingEnabled = true; int calls = 0; - var handler = (_) { + void handler(_) { calls++; - }; + } + c.onRecord.listen(handler); - root.info("foo"); - root.info("foo"); + root.info('foo'); + root.info('foo'); expect(calls, equals(0)); }); @@ -529,13 +531,18 @@ void main() { }); var callCount = 0; - var myClosure = () => "${++callCount}"; + var myClosure = () => '${++callCount}'; root.info(myClosure); 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', () { @@ -607,12 +614,7 @@ void main() { }); test('provided trace is used if given', () { - var trace; - try { - throw 'trace'; - } catch (e, t) { - trace = t; - } + var trace = StackTrace.current; var records = new List(); recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); From cb48b22240e22b1a9c717c830b1b411683e054ac Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 17 Jan 2018 21:24:00 -0800 Subject: [PATCH 082/163] Allow chrome tests to fail (dart-lang/logging#37) Pending travis-ci/travis-cidart-lang/logging#8836 fix --- pkgs/logging/.travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/logging/.travis.yml b/pkgs/logging/.travis.yml index 1e1c46c6..d2d09660 100644 --- a/pkgs/logging/.travis.yml +++ b/pkgs/logging/.travis.yml @@ -10,15 +10,16 @@ dart_task: - test: --platform chrome - test: --platform dartium install_dartium: true + - dartanalyzer matrix: include: - dart: dev dart_task: dartfmt - - dart: dev - dart_task: dartanalyzer - - dart: stable - dart_task: dartanalyzer + # TODO(travis-ci/travis-ci#8836): Remove once the travis issue is resolved. + allow_failures: + - dart_task: + test: --platform chrome # Only building master means that we don't run two builds for each pull request. branches: From af83904b71fa98ea1905ecb653c65737a57b0aa4 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 13 Feb 2018 08:56:06 -0800 Subject: [PATCH 083/163] Remove dartium from travis tests (dart-lang/logging#38) --- pkgs/logging/.travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/logging/.travis.yml b/pkgs/logging/.travis.yml index d2d09660..36f9cc8a 100644 --- a/pkgs/logging/.travis.yml +++ b/pkgs/logging/.travis.yml @@ -1,5 +1,5 @@ language: dart -sudo: false + dart: - dev - stable @@ -8,8 +8,6 @@ dart_task: - test: --platform vm - test: --platform firefox - test: --platform chrome - - test: --platform dartium - install_dartium: true - dartanalyzer matrix: From 974c007ef30a22182cfd95240067e56f3519abb5 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 16 Mar 2018 08:43:52 -0700 Subject: [PATCH 084/163] Delete PATENTS Approved by Google OSS --- pkgs/logging/PATENTS | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 pkgs/logging/PATENTS diff --git a/pkgs/logging/PATENTS b/pkgs/logging/PATENTS deleted file mode 100644 index 69541968..00000000 --- a/pkgs/logging/PATENTS +++ /dev/null @@ -1,23 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Dart Project. - -Google hereby grants to you a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this -section) patent license to make, have made, use, offer to sell, sell, -import, transfer, and otherwise run, modify and propagate the contents -of this implementation of Dart, where such license applies only to -those patent claims, both currently owned by Google and acquired in -the future, licensable by Google that are necessarily infringed by -this implementation of Dart. This grant does not include claims that -would be infringed only as a consequence of further modification of -this implementation. If you or your agent or exclusive licensee -institute or order or agree to the institution of patent litigation -against any entity (including a cross-claim or counterclaim in a -lawsuit) alleging that this implementation of Dart or any code -incorporated within this implementation of Dart constitutes direct or -contributory patent infringement, or inducement of patent -infringement, then any patent rights granted to you under this License -for this implementation of Dart shall terminate as of the date such -litigation is filed. From dc9d3f963fdc0e5f8ff3ac7b32cca45c7dc638da Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Wed, 18 Jul 2018 13:15:46 -0400 Subject: [PATCH 085/163] chore: set max SDK version to <3.0.0 (dart-lang/logging#40) --- pkgs/logging/CHANGELOG.md | 4 ++++ pkgs/logging/pubspec.yaml | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 187dc0f1..f6a9e542 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.3+2 + +* Set max SDK version to `<3.0.0`, and adjust other dependencies. + ## 0.11.3+1 * Fixed several documentation comments. diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 3dc84244..f1c89c14 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,12 +1,15 @@ name: logging -version: 0.11.4-dev -author: Dart Team +version: 0.11.3+2 + 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. +author: Dart Team homepage: https://github.com/dart-lang/logging + environment: - sdk: '>=1.5.0 <2.0.0' + sdk: '>=1.5.0 <3.0.0' + dev_dependencies: - test: '>=0.12.0 <0.13.0' + test: '>=0.12.0 <2.0.0' From 5351247efca7a24f2a10922ca1070b9b1fefafc5 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 20 Sep 2018 09:17:54 -0700 Subject: [PATCH 086/163] Update to best practices in README - Omit `new`. - Avoid an inferrable type on the listener function literal. - Avoid reduntant type when intializing logger. - Don't abbreviate "record". - Reflow to 80 characters. - Change the `[]` which were not links to backticks. --- pkgs/logging/README.md | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index de5b8c5e..04efb585 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -1,33 +1,31 @@ ## 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. +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`. +Here is a simple logging configuration that logs all messages via `print`. ```dart Logger.root.level = Level.ALL; -Logger.root.onRecord.listen((LogRecord rec) { - print('${rec.level.name}: ${rec.time}: ${rec.message}'); +Logger.root.onRecord.listen((record) { + print('${record.level.name}: ${record.time}: ${record.message}'); }); ``` -First, set the root [Level]. All messages at or above the level are -sent to the [onRecord] stream. +First, set the root `Level`. All messages at or above the level are sent to the +`onRecord` stream. -Then, listen on the [onRecord] stream for [LogRecord] events. The -[LogRecord] class has various properties for the message, error, -logger name, and more. +Then, listen on the `onRecord` stream for `LogRecord` events. The `LogRecord` +class has various properties for the message, error, logger name, and more. ## Logging messages -Create a [Logger] with a unique name to easily identify the source -of the log messages. +Create a `Logger` with a unique name to easily identify the source of the log +messages. ```dart -final Logger log = new Logger('MyClassName'); +final log = Logger('MyClassName'); ``` Here is an example of logging a debug message and an error: @@ -39,11 +37,11 @@ var future = doSomethingAsync().then((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: +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("-")); ``` -See the [Logger] class for the different logging methods. +See the `Logger` class for the different logging methods. From a8c0425baa2105a73a60afa2e5a84c0e3faae09e Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Sat, 27 Oct 2018 08:53:15 -0700 Subject: [PATCH 087/163] Update README.md --- pkgs/logging/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 04efb585..9d9da585 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -1,3 +1,7 @@ +# Logging for Dart + +[![Build Status](https://travis-ci.org/dart-lang/logging.svg?branch=master)](https://travis-ci.org/dart-lang/logging) + ## Initializing By default, the logging package does not do anything useful with the log From 776e8ad88e943d4d6561805bc23015656bb4ed22 Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Sat, 27 Oct 2018 12:15:48 -0700 Subject: [PATCH 088/163] Update README.md --- pkgs/logging/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 9d9da585..b7c11ce1 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -1,5 +1,3 @@ -# Logging for Dart - [![Build Status](https://travis-ci.org/dart-lang/logging.svg?branch=master)](https://travis-ci.org/dart-lang/logging) ## Initializing From 898d4fac9d26a529b3d38fd1f6484fd7f8c6572b Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Sat, 27 Oct 2018 12:20:23 -0700 Subject: [PATCH 089/163] Update README.md --- pkgs/logging/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index b7c11ce1..252a68d3 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -1,4 +1,5 @@ [![Build Status](https://travis-ci.org/dart-lang/logging.svg?branch=master)](https://travis-ci.org/dart-lang/logging) +[![Pub](https://img.shields.io/pub/v/logging.svg)](https://pub.dartlang.org/packages/logging) ## Initializing From 343a55e07b4b55e926a98c0976032a7e579e816b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 27 Oct 2018 12:45:53 -0700 Subject: [PATCH 090/163] dartfmt --fix, update min SDK to 2.0.0 --- pkgs/logging/lib/logging.dart | 48 +++++++++++----------- pkgs/logging/pubspec.yaml | 6 +-- pkgs/logging/test/logging_test.dart | 64 ++++++++++++++--------------- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index e278d765..f69ed697 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -52,7 +52,7 @@ class Logger { /// Singleton constructor. Calling `new Logger(name)` will return the same /// actual instance whenever it is called with the same string name. factory Logger(String name) { - return _loggers.putIfAbsent(name, () => new Logger._named(name)); + return _loggers.putIfAbsent(name, () => Logger._named(name)); } /// Creates a new detached [Logger]. @@ -64,30 +64,30 @@ class Logger { /// It can be useful when you just need a local short-living logger, /// which you'd like to be garbage-collected later. factory Logger.detached(String name) { - return new Logger._internal(name, null, new Map()); + return Logger._internal(name, null, Map()); } factory Logger._named(String name) { if (name.startsWith('.')) { - throw new ArgumentError("name shouldn't start with a '.'"); + throw ArgumentError("name shouldn't start with a '.'"); } // Split hierarchical names (separated with '.'). int dot = name.lastIndexOf('.'); Logger parent; String thisName; if (dot == -1) { - if (name != '') parent = new Logger(''); + if (name != '') parent = Logger(''); thisName = name; } else { - parent = new Logger(name.substring(0, dot)); + parent = Logger(name.substring(0, dot)); thisName = name.substring(dot + 1); } - return new Logger._internal(thisName, parent, new Map()); + return Logger._internal(thisName, parent, Map()); } Logger._internal(this.name, this.parent, Map children) : this._children = children, - this.children = new UnmodifiableMapView(children) { + this.children = UnmodifiableMapView(children) { if (parent != null) parent._children[name] = this; } @@ -107,7 +107,7 @@ class Logger { _level = value; } else { if (parent != null) { - throw new UnsupportedError( + throw UnsupportedError( 'Please set "hierarchicalLoggingEnabled" to true if you want to ' 'change the level on a non-root logger.'); } @@ -177,8 +177,8 @@ class Logger { } if (zone == null) zone = Zone.current; - var record = new LogRecord( - logLevel, msg, fullName, error, stackTrace, zone, object); + var record = + LogRecord(logLevel, msg, fullName, error, stackTrace, zone, object); if (hierarchicalLoggingEnabled) { var target = this; @@ -227,7 +227,7 @@ class Logger { Stream _getStream() { if (hierarchicalLoggingEnabled || parent == null) { if (_controller == null) { - _controller = new StreamController.broadcast(sync: true); + _controller = StreamController.broadcast(sync: true); } return _controller.stream; } else { @@ -242,7 +242,7 @@ class Logger { } /// Top-level root [Logger]. - static final Logger root = new Logger(''); + static final Logger root = Logger(''); /// All [Logger]s in the system. static final Map _loggers = {}; @@ -271,36 +271,36 @@ class Level implements Comparable { const Level(this.name, this.value); /// Special key to turn on logging for all levels ([value] = 0). - static const Level ALL = const Level('ALL', 0); + static const Level ALL = Level('ALL', 0); /// Special key to turn off all logging ([value] = 2000). - static const Level OFF = const Level('OFF', 2000); + static const Level OFF = Level('OFF', 2000); /// Key for highly detailed tracing ([value] = 300). - static const Level FINEST = const Level('FINEST', 300); + static const Level FINEST = Level('FINEST', 300); /// Key for fairly detailed tracing ([value] = 400). - static const Level FINER = const Level('FINER', 400); + static const Level FINER = Level('FINER', 400); /// Key for tracing information ([value] = 500). - static const Level FINE = const Level('FINE', 500); + static const Level FINE = Level('FINE', 500); /// Key for static configuration messages ([value] = 700). - static const Level CONFIG = const Level('CONFIG', 700); + static const Level CONFIG = Level('CONFIG', 700); /// Key for informational messages ([value] = 800). - static const Level INFO = const Level('INFO', 800); + static const Level INFO = Level('INFO', 800); /// Key for potential problems ([value] = 900). - static const Level WARNING = const Level('WARNING', 900); + static const Level WARNING = Level('WARNING', 900); /// Key for serious failures ([value] = 1000). - static const Level SEVERE = const Level('SEVERE', 1000); + static const Level SEVERE = Level('SEVERE', 1000); /// Key for extra debugging loudness ([value] = 1200). - static const Level SHOUT = const Level('SHOUT', 1200); + static const Level SHOUT = Level('SHOUT', 1200); - static const List LEVELS = const [ + static const List LEVELS = [ ALL, FINEST, FINER, @@ -361,7 +361,7 @@ class LogRecord { LogRecord(this.level, this.message, this.loggerName, [this.error, this.stackTrace, this.zone, this.object]) - : time = new DateTime.now(), + : time = DateTime.now(), sequenceNumber = LogRecord._nextNumber++; @override diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index f1c89c14..36213172 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,7 +1,7 @@ name: logging -version: 0.11.3+2 +version: 0.11.4-dev -description: > +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. @@ -9,7 +9,7 @@ author: Dart Team homepage: https://github.com/dart-lang/logging environment: - sdk: '>=1.5.0 <3.0.0' + sdk: '>=2.0.0 <3.0.0' dev_dependencies: test: '>=0.12.0 <2.0.0' diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index c8543449..c384b556 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -62,7 +62,7 @@ void main() { }); test('levels are hashable', () { - var map = new Map(); + var map = Map(); map[Level.INFO] = 'info'; map[Level.SHOUT] = 'shout'; expect(map[Level.INFO], same('info')); @@ -70,11 +70,11 @@ void main() { }); test('logger name cannot start with a "." ', () { - expect(() => new Logger('.c'), throwsArgumentError); + expect(() => Logger('.c'), throwsArgumentError); }); test('logger naming is hierarchical', () { - Logger c = new Logger('a.b.c'); + Logger c = Logger('a.b.c'); expect(c.name, equals('c')); expect(c.parent.name, equals('b')); expect(c.parent.parent.name, equals('a')); @@ -83,7 +83,7 @@ void main() { }); test('logger full name', () { - Logger c = new Logger('a.b.c'); + Logger c = Logger('a.b.c'); expect(c.fullName, equals('a.b.c')); expect(c.parent.fullName, equals('a.b')); expect(c.parent.parent.fullName, equals('a')); @@ -92,9 +92,9 @@ void main() { }); test('logger parent-child links are correct', () { - Logger a = new Logger('a'); - Logger b = new Logger('a.b'); - Logger c = new Logger('a.c'); + Logger a = Logger('a'); + Logger b = Logger('a.b'); + Logger c = Logger('a.c'); expect(a, same(b.parent)); expect(a, same(c.parent)); expect(a.children['b'], same(b)); @@ -102,18 +102,18 @@ void main() { }); test('loggers are singletons', () { - Logger a1 = new Logger('a'); - Logger a2 = new Logger('a'); - Logger b = new Logger('a.b'); + Logger a1 = Logger('a'); + Logger a2 = Logger('a'); + Logger b = Logger('a.b'); Logger root = Logger.root; expect(a1, same(a2)); expect(a1, same(b.parent)); expect(root, same(a1.parent)); - expect(root, same(new Logger(''))); + expect(root, same(Logger(''))); }); test('cannot directly manipulate Logger.children', () { - var loggerAB = new Logger('a.b'); + var loggerAB = Logger('a.b'); var loggerA = loggerAB.parent; expect(loggerA.children['b'], same(loggerAB), reason: 'can read Children'); @@ -126,12 +126,12 @@ void main() { test('stackTrace gets throw to LogRecord', () { Logger.root.level = Level.INFO; - var records = new List(); + var records = List(); var sub = Logger.root.onRecord.listen(records.add); try { - throw new UnsupportedError('test exception'); + throw UnsupportedError('test exception'); } catch (error, stack) { Logger.root.log(Level.SEVERE, 'severe', error, stack); Logger.root.warning('warning', error, stack); @@ -164,7 +164,7 @@ void main() { var root = Logger.root; var recordingZone = Zone.current; - var records = new List(); + var records = List(); root.onRecord.listen(records.add); root.info('hello'); @@ -176,7 +176,7 @@ void main() { var root = Logger.root; var recordingZone; - var records = new List(); + var records = List(); root.onRecord.listen(records.add); runZoned(() { @@ -192,7 +192,7 @@ void main() { var root = Logger.root; Zone recordingZone; - var records = new List(); + var records = List(); root.onRecord.listen(records.add); runZoned(() { @@ -208,9 +208,9 @@ void main() { group('detached loggers', () { test('create new instances of Logger', () { - Logger a1 = new Logger.detached('a'); - Logger a2 = new Logger.detached('a'); - Logger a = new Logger('a'); + Logger a1 = Logger.detached('a'); + Logger a2 = Logger.detached('a'); + Logger a = Logger('a'); expect(a1, isNot(a2)); expect(a1, isNot(a)); @@ -218,23 +218,23 @@ void main() { }); test('parent is null', () { - Logger a = new Logger.detached('a'); + Logger a = Logger.detached('a'); expect(a.parent, null); }); test('children is empty', () { - Logger a = new Logger.detached('a'); + Logger a = Logger.detached('a'); expect(a.children, {}); }); }); group('mutating levels', () { Logger root = Logger.root; - Logger a = new Logger('a'); - Logger b = new Logger('a.b'); - Logger c = new Logger('a.b.c'); - Logger d = new Logger('a.b.c.d'); - Logger e = new Logger('a.b.c.d.e'); + Logger a = Logger('a'); + Logger b = Logger('a.b'); + Logger c = Logger('a.b.c'); + Logger d = Logger('a.b.c.d'); + Logger e = Logger('a.b.c.d.e'); setUp(() { hierarchicalLoggingEnabled = true; @@ -549,7 +549,7 @@ void main() { root.level = Level.INFO; var messages = []; var objects = []; - var object = new Object(); + var object = Object(); root.onRecord.listen((record) { messages.add('${record.level}: ${record.message}'); objects.add(record.object); @@ -589,7 +589,7 @@ void main() { }); test('no stack trace by default', () { - var records = new List(); + var records = List(); root.onRecord.listen(records.add); root.severe('hello'); root.warning('hello'); @@ -601,7 +601,7 @@ void main() { }); test('trace recorded only on requested levels', () { - var records = new List(); + var records = List(); recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); root.severe('hello'); @@ -615,7 +615,7 @@ void main() { test('provided trace is used if given', () { var trace = StackTrace.current; - var records = new List(); + var records = List(); recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); root.severe('hello'); @@ -626,7 +626,7 @@ void main() { }); test('error also generated when generating a trace', () { - var records = new List(); + var records = List(); recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); root.severe('hello'); From b8e1b54859ab00b6637d4ad8d75a1a8e968c0fce Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 27 Oct 2018 12:51:21 -0700 Subject: [PATCH 091/163] Enable a number of new lints --- pkgs/logging/CHANGELOG.md | 4 ++ pkgs/logging/analysis_options.yaml | 39 ++++++++++++++--- pkgs/logging/lib/logging.dart | 16 +++---- pkgs/logging/pubspec.yaml | 3 +- pkgs/logging/test/logging_test.dart | 68 ++++++++++++++--------------- 5 files changed, 81 insertions(+), 49 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index f6a9e542..393a25f0 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.4 + +* Require Dart `>=2.0.0`. + ## 0.11.3+2 * Set max SDK version to `<3.0.0`, and adjust other dependencies. diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index 848b33ff..b185e472 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -1,3 +1,4 @@ +include: package:pedantic/analysis_options.yaml analyzer: strong-mode: implicit-casts: false @@ -9,12 +10,18 @@ analyzer: linter: rules: - annotate_overrides - - avoid_empty_else + - avoid_function_literals_in_foreach_calls - avoid_init_to_null - - avoid_return_types_on_setters + - avoid_null_checks_in_equality_operators + - avoid_relative_lib_imports + - avoid_returning_null + - avoid_unused_constructor_parameters - await_only_futures - camel_case_types + - cancel_subscriptions - comment_references + # See https://github.com/dart-lang/logging/issues/43 + #- constant_identifier_names - control_flow_in_finally - directives_ordering - empty_catches @@ -22,17 +29,39 @@ linter: - empty_statements - hash_and_equals - implementation_imports + - invariant_booleans + - iterable_contains_unrelated_type - library_names - library_prefixes + - list_remove_unrelated_type + - no_adjacent_strings_in_list - non_constant_identifier_names + - omit_local_variable_types - only_throw_errors + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + - prefer_adjacent_string_concatenation + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors - prefer_final_fields - - prefer_is_not_empty + - prefer_initializing_formals + - prefer_interpolation_to_compose_strings - prefer_single_quotes + - prefer_typing_uninitialized_variables - slash_for_doc_comments - test_types_in_equals + - super_goes_last - test_types_in_equals - throw_in_finally - type_init_formals - - unrelated_type_equality_checks - - valid_regexps + - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_statements + - unnecessary_this diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index f69ed697..7c2745ce 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -64,7 +64,7 @@ class Logger { /// It can be useful when you just need a local short-living logger, /// which you'd like to be garbage-collected later. factory Logger.detached(String name) { - return Logger._internal(name, null, Map()); + return Logger._internal(name, null, {}); } factory Logger._named(String name) { @@ -72,7 +72,7 @@ class Logger { throw ArgumentError("name shouldn't start with a '.'"); } // Split hierarchical names (separated with '.'). - int dot = name.lastIndexOf('.'); + var dot = name.lastIndexOf('.'); Logger parent; String thisName; if (dot == -1) { @@ -82,12 +82,12 @@ class Logger { parent = Logger(name.substring(0, dot)); thisName = name.substring(dot + 1); } - return Logger._internal(thisName, parent, Map()); + return Logger._internal(thisName, parent, {}); } Logger._internal(this.name, this.parent, Map children) - : this._children = children, - this.children = UnmodifiableMapView(children) { + : _children = children, + children = UnmodifiableMapView(children) { if (parent != null) parent._children[name] = this; } @@ -175,7 +175,7 @@ class Logger { stackTrace = StackTrace.current; error ??= 'autogenerated stack trace for $logLevel $msg'; } - if (zone == null) zone = Zone.current; + zone ??= Zone.current; var record = LogRecord(logLevel, msg, fullName, error, stackTrace, zone, object); @@ -226,9 +226,7 @@ class Logger { Stream _getStream() { if (hierarchicalLoggingEnabled || parent == null) { - if (_controller == null) { - _controller = StreamController.broadcast(sync: true); - } + _controller ??= StreamController.broadcast(sync: true); return _controller.stream; } else { return root._getStream(); diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 36213172..9eba1879 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -12,4 +12,5 @@ environment: sdk: '>=2.0.0 <3.0.0' dev_dependencies: - test: '>=0.12.0 <2.0.0' + pedantic: ^1.3.0 + test: ^1.3.0 diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index c384b556..b24a8a99 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -32,8 +32,8 @@ void main() { test('default levels are in order', () { final levels = Level.LEVELS; - for (int i = 0; i < levels.length; i++) { - for (int j = i + 1; j < levels.length; j++) { + for (var i = 0; i < levels.length; i++) { + for (var j = i + 1; j < levels.length; j++) { expect(levels[i] < levels[j], isTrue); } } @@ -62,7 +62,7 @@ void main() { }); test('levels are hashable', () { - var map = Map(); + var map = {}; map[Level.INFO] = 'info'; map[Level.SHOUT] = 'shout'; expect(map[Level.INFO], same('info')); @@ -74,7 +74,7 @@ void main() { }); test('logger naming is hierarchical', () { - Logger c = Logger('a.b.c'); + var c = Logger('a.b.c'); expect(c.name, equals('c')); expect(c.parent.name, equals('b')); expect(c.parent.parent.name, equals('a')); @@ -83,7 +83,7 @@ void main() { }); test('logger full name', () { - Logger c = Logger('a.b.c'); + var c = Logger('a.b.c'); expect(c.fullName, equals('a.b.c')); expect(c.parent.fullName, equals('a.b')); expect(c.parent.parent.fullName, equals('a')); @@ -92,9 +92,9 @@ void main() { }); test('logger parent-child links are correct', () { - Logger a = Logger('a'); - Logger b = Logger('a.b'); - Logger c = Logger('a.c'); + var a = Logger('a'); + var b = Logger('a.b'); + var c = Logger('a.c'); expect(a, same(b.parent)); expect(a, same(c.parent)); expect(a.children['b'], same(b)); @@ -102,10 +102,10 @@ void main() { }); test('loggers are singletons', () { - Logger a1 = Logger('a'); - Logger a2 = Logger('a'); - Logger b = Logger('a.b'); - Logger root = Logger.root; + var a1 = Logger('a'); + var a2 = Logger('a'); + var b = Logger('a.b'); + var root = Logger.root; expect(a1, same(a2)); expect(a1, same(b.parent)); expect(root, same(a1.parent)); @@ -126,7 +126,7 @@ void main() { test('stackTrace gets throw to LogRecord', () { Logger.root.level = Level.INFO; - var records = List(); + var records = []; var sub = Logger.root.onRecord.listen(records.add); @@ -164,7 +164,7 @@ void main() { var root = Logger.root; var recordingZone = Zone.current; - var records = List(); + var records = []; root.onRecord.listen(records.add); root.info('hello'); @@ -175,8 +175,8 @@ void main() { test('child zone', () { var root = Logger.root; - var recordingZone; - var records = List(); + Zone recordingZone; + var records = []; root.onRecord.listen(records.add); runZoned(() { @@ -192,7 +192,7 @@ void main() { var root = Logger.root; Zone recordingZone; - var records = List(); + var records = []; root.onRecord.listen(records.add); runZoned(() { @@ -208,9 +208,9 @@ void main() { group('detached loggers', () { test('create new instances of Logger', () { - Logger a1 = Logger.detached('a'); - Logger a2 = Logger.detached('a'); - Logger a = Logger('a'); + var a1 = Logger.detached('a'); + var a2 = Logger.detached('a'); + var a = Logger('a'); expect(a1, isNot(a2)); expect(a1, isNot(a)); @@ -218,23 +218,23 @@ void main() { }); test('parent is null', () { - Logger a = Logger.detached('a'); + var a = Logger.detached('a'); expect(a.parent, null); }); test('children is empty', () { - Logger a = Logger.detached('a'); + var a = Logger.detached('a'); expect(a.children, {}); }); }); group('mutating levels', () { - Logger root = Logger.root; - Logger a = Logger('a'); - Logger b = Logger('a.b'); - Logger c = Logger('a.b.c'); - Logger d = Logger('a.b.c.d'); - Logger e = Logger('a.b.c.d.e'); + var root = Logger.root; + var a = Logger('a'); + var b = Logger('a.b'); + var c = Logger('a.b.c'); + var d = Logger('a.b.c.d'); + var e = Logger('a.b.c.d.e'); setUp(() { hierarchicalLoggingEnabled = true; @@ -303,7 +303,7 @@ void main() { }); test('add/remove handlers - no hierarchy', () { - int calls = 0; + var calls = 0; void handler(_) { calls++; } @@ -319,7 +319,7 @@ void main() { test('add/remove handlers - with hierarchy', () { hierarchicalLoggingEnabled = true; - int calls = 0; + var calls = 0; void handler(_) { calls++; } @@ -589,7 +589,7 @@ void main() { }); test('no stack trace by default', () { - var records = List(); + var records = []; root.onRecord.listen(records.add); root.severe('hello'); root.warning('hello'); @@ -601,7 +601,7 @@ void main() { }); test('trace recorded only on requested levels', () { - var records = List(); + var records = []; recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); root.severe('hello'); @@ -615,7 +615,7 @@ void main() { test('provided trace is used if given', () { var trace = StackTrace.current; - var records = List(); + var records = []; recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); root.severe('hello'); @@ -626,7 +626,7 @@ void main() { }); test('error also generated when generating a trace', () { - var records = List(); + var records = []; recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); root.severe('hello'); From a7288c359be2781a86f2fae306956875c6e9d3bd Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 27 Oct 2018 12:52:53 -0700 Subject: [PATCH 092/163] Only test one browser --- pkgs/logging/.travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkgs/logging/.travis.yml b/pkgs/logging/.travis.yml index 36f9cc8a..bc200e85 100644 --- a/pkgs/logging/.travis.yml +++ b/pkgs/logging/.travis.yml @@ -6,18 +6,13 @@ dart: dart_task: - test: --platform vm - - test: --platform firefox - test: --platform chrome - - dartanalyzer + - dartanalyzer: --fatal-infos --fatal-warnings . matrix: include: - dart: dev dart_task: dartfmt - # TODO(travis-ci/travis-ci#8836): Remove once the travis issue is resolved. - allow_failures: - - dart_task: - test: --platform chrome # Only building master means that we don't run two builds for each pull request. branches: From f5caf235e43b47362fcd22be55739b7441d37e71 Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Tue, 30 Oct 2018 15:29:14 -0700 Subject: [PATCH 093/163] minor cleanups (dart-lang/logging#50) * typedef syntax; => shorthand --- pkgs/logging/lib/logging.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index 7c2745ce..ba8c529d 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -51,9 +51,8 @@ class Logger { /// Singleton constructor. Calling `new Logger(name)` will return the same /// actual instance whenever it is called with the same string name. - factory Logger(String name) { - return _loggers.putIfAbsent(name, () => Logger._named(name)); - } + factory Logger(String name) => + _loggers.putIfAbsent(name, () => Logger._named(name)); /// Creates a new detached [Logger]. /// @@ -63,9 +62,8 @@ class Logger { /// /// It can be useful when you just need a local short-living logger, /// which you'd like to be garbage-collected later. - factory Logger.detached(String name) { - return Logger._internal(name, null, {}); - } + factory Logger.detached(String name) => + Logger._internal(name, null, {}); factory Logger._named(String name) { if (name.startsWith('.')) { @@ -247,7 +245,8 @@ class Logger { } /// Handler callback to process log entries as they are added to a [Logger]. -typedef void LoggerHandler(LogRecord record); +@deprecated +typedef LoggerHandler = void Function(LogRecord record); /// [Level]s to control logging output. Logging can be enabled to include all /// levels above certain [Level]. [Level]s are ordered using an integer From d1ec82ad1f7878597dca0e044c68280499792a1d Mon Sep 17 00:00:00 2001 From: Jonas Finnemann Jensen Date: Tue, 12 Mar 2019 19:33:02 +0100 Subject: [PATCH 094/163] Document default LogLevel (dart-lang/logging#58) --- pkgs/logging/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 252a68d3..056ef696 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -10,7 +10,7 @@ messages. Here is a simple logging configuration that logs all messages via `print`. ```dart -Logger.root.level = Level.ALL; +Logger.root.level = Level.ALL; // defaults to Level.INFO Logger.root.onRecord.listen((record) { print('${record.level.name}: ${record.time}: ${record.message}'); }); From a4cfb986e123dd7ac14db4a49b6d8d0683efdae8 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 29 Apr 2019 07:32:44 -0700 Subject: [PATCH 095/163] Test travis on oldest supported SDK (dart-lang/logging#59) --- pkgs/logging/.gitignore | 3 +-- pkgs/logging/.travis.yml | 2 +- pkgs/logging/analysis_options.yaml | 2 -- pkgs/logging/codereview.settings | 3 --- 4 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 pkgs/logging/codereview.settings diff --git a/pkgs/logging/.gitignore b/pkgs/logging/.gitignore index aac1f4fe..79f51c3d 100644 --- a/pkgs/logging/.gitignore +++ b/pkgs/logging/.gitignore @@ -1,4 +1,3 @@ +.dart_tool .packages -.pub -packages pubspec.lock diff --git a/pkgs/logging/.travis.yml b/pkgs/logging/.travis.yml index bc200e85..cb069312 100644 --- a/pkgs/logging/.travis.yml +++ b/pkgs/logging/.travis.yml @@ -2,7 +2,7 @@ language: dart dart: - dev - - stable + - 2.0.0 dart_task: - test: --platform vm diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index b185e472..7b4600f4 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -53,8 +53,6 @@ linter: - prefer_typing_uninitialized_variables - slash_for_doc_comments - test_types_in_equals - - super_goes_last - - test_types_in_equals - throw_in_finally - type_init_formals - unnecessary_brace_in_string_interps diff --git a/pkgs/logging/codereview.settings b/pkgs/logging/codereview.settings deleted file mode 100644 index ae2cae66..00000000 --- a/pkgs/logging/codereview.settings +++ /dev/null @@ -1,3 +0,0 @@ -CODE_REVIEW_SERVER: http://codereview.chromium.org/ -VIEW_VC: https://github.com/dart-lang/logging/commit/ -CC_LIST: reviews@dartlang.org \ No newline at end of file From 194b95392d078fcc3cb6021ed264db1b675ec8ae Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 18 Jun 2019 10:04:50 -0700 Subject: [PATCH 096/163] Fix dartlang.org links and add a missing dartfmt lint (dart-lang/logging#62) --- pkgs/logging/CHANGELOG.md | 3 +-- pkgs/logging/README.md | 2 +- pkgs/logging/analysis_options.yaml | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 393a25f0..3017f898 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -37,7 +37,7 @@ * 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.dartlang.org/packages/stack_trace +[stack_trace package]: https://pub.dev/packages/stack_trace ## 0.10.0 @@ -48,4 +48,3 @@ * Added optional `LogRecord.zone` field. * Record current zone (or user specified zone) when creating new `LogRecord`s. - diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 056ef696..fe2ef543 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -1,5 +1,5 @@ [![Build Status](https://travis-ci.org/dart-lang/logging.svg?branch=master)](https://travis-ci.org/dart-lang/logging) -[![Pub](https://img.shields.io/pub/v/logging.svg)](https://pub.dartlang.org/packages/logging) +[![Pub](https://img.shields.io/pub/v/logging.svg)](https://pub.dev/packages/logging) ## Initializing diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index 7b4600f4..fbe6079f 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -47,6 +47,7 @@ linter: - prefer_conditional_assignment - prefer_const_constructors - prefer_final_fields + - prefer_generic_function_type_aliases - prefer_initializing_formals - prefer_interpolation_to_compose_strings - prefer_single_quotes From 03783e3b17364f9a4c72851b1c2dfc3e48e3d517 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 2 Aug 2019 11:56:35 -0700 Subject: [PATCH 097/163] Refactor into mini-libraries (dart-lang/logging#64) --- pkgs/logging/lib/logging.dart | 364 +-------------------------- pkgs/logging/lib/src/level.dart | 86 +++++++ pkgs/logging/lib/src/log_record.dart | 42 ++++ pkgs/logging/lib/src/logger.dart | 242 ++++++++++++++++++ 4 files changed, 376 insertions(+), 358 deletions(-) create mode 100644 pkgs/logging/lib/src/level.dart create mode 100644 pkgs/logging/lib/src/log_record.dart create mode 100644 pkgs/logging/lib/src/logger.dart diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index ba8c529d..f84bbb1a 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -2,365 +2,13 @@ // 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; +import 'src/log_record.dart'; +import 'src/logger.dart'; -import 'dart:async'; -import 'dart:collection'; - -/// Whether to allow fine-grain logging and configuration of loggers in a -/// hierarchy. -/// -/// When false, all logging is merged in the root logger. -bool hierarchicalLoggingEnabled = false; - -/// Automatically record stack traces for any message of this level or above. -/// -/// Because this is expensive, this is off by default. -Level recordStackTraceAtLevel = Level.OFF; - -/// Level for the root-logger. -/// -/// This will be the level of all loggers if [hierarchicalLoggingEnabled] is -/// false. -Level _rootLevel = Level.INFO; - -/// Use a [Logger] to log debug messages. -/// -/// [Logger]s are named using a hierarchical dot-separated name convention. -class Logger { - /// Simple name of this logger. - final String name; - - /// The full name of this logger, which includes the parent's full name. - String get fullName => - (parent == null || parent.name == '') ? name : '${parent.fullName}.$name'; - - /// Parent of this logger in the hierarchy of loggers. - final Logger parent; - - /// Logging [Level] used for entries generated on this logger. - Level _level; - - final Map _children; - - /// Children in the hierarchy of loggers, indexed by their simple names. - final Map children; - - /// Controller used to notify when log entries are added to this logger. - StreamController _controller; - - /// Singleton constructor. Calling `new Logger(name)` will return the same - /// actual instance whenever it is called with the same string name. - factory Logger(String name) => - _loggers.putIfAbsent(name, () => Logger._named(name)); - - /// Creates a new detached [Logger]. - /// - /// Returns a new [Logger] instance (unlike `new Logger`, which returns a - /// [Logger] singleton), which doesn't have any parent or children, - /// and is not a part of the global hierarchical loggers structure. - /// - /// It can be useful when you just need a local short-living logger, - /// which you'd like to be garbage-collected later. - factory Logger.detached(String name) => - Logger._internal(name, null, {}); - - factory Logger._named(String name) { - if (name.startsWith('.')) { - throw ArgumentError("name shouldn't start with a '.'"); - } - // Split hierarchical names (separated with '.'). - var dot = name.lastIndexOf('.'); - Logger parent; - String thisName; - if (dot == -1) { - if (name != '') parent = Logger(''); - thisName = name; - } else { - parent = Logger(name.substring(0, dot)); - thisName = name.substring(dot + 1); - } - return Logger._internal(thisName, parent, {}); - } - - Logger._internal(this.name, this.parent, Map children) - : _children = children, - children = UnmodifiableMapView(children) { - if (parent != null) parent._children[name] = this; - } - - /// Effective level considering the levels established in this logger's - /// parents (when [hierarchicalLoggingEnabled] is true). - Level get level { - if (hierarchicalLoggingEnabled) { - if (_level != null) return _level; - if (parent != null) return parent.level; - } - return _rootLevel; - } - - /// Override the level for this particular [Logger] and its children. - set level(Level value) { - if (hierarchicalLoggingEnabled && parent != null) { - _level = value; - } else { - if (parent != null) { - throw UnsupportedError( - 'Please set "hierarchicalLoggingEnabled" to true if you want to ' - 'change the level on a non-root logger.'); - } - _rootLevel = value; - } - } - - /// Returns a stream of messages added to this [Logger]. - /// - /// You can listen for messages using the standard stream APIs, for instance: - /// - /// ```dart - /// logger.onRecord.listen((record) { ... }); - /// ``` - Stream get onRecord => _getStream(); - - void clearListeners() { - if (hierarchicalLoggingEnabled || parent == null) { - if (_controller != null) { - _controller.close(); - _controller = null; - } - } else { - root.clearListeners(); - } - } - - /// Whether a message for [value]'s level is loggable in this logger. - bool isLoggable(Level value) => (value >= level); - - /// Adds a log record for a [message] at a particular [logLevel] if - /// `isLoggable(logLevel)` is true. - /// - /// Use this method to create log entries for user-defined levels. To record a - /// message at a predefined level (e.g. [Level.INFO], [Level.WARNING], etc) - /// you can use their specialized methods instead (e.g. [info], [warning], - /// etc). - /// - /// If [message] is a [Function], it will be lazy evaluated. Additionally, if - /// [message] or its evaluated value is not a [String], then 'toString()' will - /// be called on the object and the result will be logged. The log record will - /// contain a field holding the original object. - /// - /// The log record will also contain a field for the zone in which this call - /// was made. This can be advantageous if a log listener wants to handler - /// records of 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]) { - Object object; - if (isLoggable(logLevel)) { - if (message is Function) { - message = message(); - } - - String msg; - if (message is String) { - msg = message; - } else { - msg = message.toString(); - object = message; - } - - if (stackTrace == null && logLevel >= recordStackTraceAtLevel) { - stackTrace = StackTrace.current; - error ??= 'autogenerated stack trace for $logLevel $msg'; - } - zone ??= Zone.current; - - var record = - LogRecord(logLevel, msg, fullName, error, stackTrace, zone, object); - - if (hierarchicalLoggingEnabled) { - var target = this; - while (target != null) { - target._publish(record); - target = target.parent; - } - } else { - root._publish(record); - } - } - } - - /// Log message at level [Level.FINEST]. - void finest(message, [Object error, StackTrace stackTrace]) => - log(Level.FINEST, message, error, stackTrace); - - /// Log message at level [Level.FINER]. - void finer(message, [Object error, StackTrace stackTrace]) => - log(Level.FINER, message, error, stackTrace); - - /// Log message at level [Level.FINE]. - void fine(message, [Object error, StackTrace stackTrace]) => - log(Level.FINE, message, error, stackTrace); - - /// Log message at level [Level.CONFIG]. - void config(message, [Object error, StackTrace stackTrace]) => - log(Level.CONFIG, message, error, stackTrace); - - /// Log message at level [Level.INFO]. - void info(message, [Object error, StackTrace stackTrace]) => - log(Level.INFO, message, error, stackTrace); - - /// Log message at level [Level.WARNING]. - void warning(message, [Object error, StackTrace stackTrace]) => - log(Level.WARNING, message, error, stackTrace); - - /// Log message at level [Level.SEVERE]. - void severe(message, [Object error, StackTrace stackTrace]) => - log(Level.SEVERE, message, error, stackTrace); - - /// Log message at level [Level.SHOUT]. - void shout(message, [Object error, StackTrace stackTrace]) => - log(Level.SHOUT, message, error, stackTrace); - - Stream _getStream() { - if (hierarchicalLoggingEnabled || parent == null) { - _controller ??= StreamController.broadcast(sync: true); - return _controller.stream; - } else { - return root._getStream(); - } - } - - void _publish(LogRecord record) { - if (_controller != null) { - _controller.add(record); - } - } - - /// Top-level root [Logger]. - static final Logger root = Logger(''); - - /// All [Logger]s in the system. - static final Map _loggers = {}; -} +export 'src/level.dart'; +export 'src/log_record.dart'; +export 'src/logger.dart'; /// Handler callback to process log entries as they are added to a [Logger]. -@deprecated +@Deprecated('Will be removed in 1.0.0') typedef LoggerHandler = void Function(LogRecord record); - -/// [Level]s to control logging output. Logging can be enabled to include all -/// levels above certain [Level]. [Level]s are ordered using an integer -/// value [Level.value]. The predefined [Level] constants below are sorted as -/// follows (in descending order): [Level.SHOUT], [Level.SEVERE], -/// [Level.WARNING], [Level.INFO], [Level.CONFIG], [Level.FINE], [Level.FINER], -/// [Level.FINEST], and [Level.ALL]. -/// -/// We recommend using one of the predefined logging levels. If you define your -/// own level, make sure you use a value between those used in [Level.ALL] and -/// [Level.OFF]. -class Level implements Comparable { - final String name; - - /// Unique value for this level. Used to order levels, so filtering can - /// exclude messages whose level is under certain value. - final int value; - - const Level(this.name, this.value); - - /// Special key to turn on logging for all levels ([value] = 0). - static const Level ALL = Level('ALL', 0); - - /// Special key to turn off all logging ([value] = 2000). - static const Level OFF = Level('OFF', 2000); - - /// Key for highly detailed tracing ([value] = 300). - static const Level FINEST = Level('FINEST', 300); - - /// Key for fairly detailed tracing ([value] = 400). - static const Level FINER = Level('FINER', 400); - - /// Key for tracing information ([value] = 500). - static const Level FINE = Level('FINE', 500); - - /// Key for static configuration messages ([value] = 700). - static const Level CONFIG = Level('CONFIG', 700); - - /// Key for informational messages ([value] = 800). - static const Level INFO = Level('INFO', 800); - - /// Key for potential problems ([value] = 900). - static const Level WARNING = Level('WARNING', 900); - - /// Key for serious failures ([value] = 1000). - static const Level SEVERE = Level('SEVERE', 1000); - - /// Key for extra debugging loudness ([value] = 1200). - static const Level SHOUT = Level('SHOUT', 1200); - - static const List LEVELS = [ - ALL, - FINEST, - FINER, - FINE, - CONFIG, - INFO, - WARNING, - SEVERE, - SHOUT, - OFF - ]; - - @override - bool operator ==(Object other) => other is Level && value == other.value; - bool operator <(Level other) => value < other.value; - bool operator <=(Level other) => value <= other.value; - bool operator >(Level other) => value > other.value; - bool operator >=(Level other) => value >= other.value; - - @override - int compareTo(Level other) => value - other.value; - - @override - int get hashCode => value; - - @override - String toString() => name; -} - -/// A log entry representation used to propagate information from [Logger] to -/// individual handlers. -class LogRecord { - final Level level; - final String message; - - /// Non-string message passed to Logger. - final Object object; - - /// Logger where this record is stored. - final String loggerName; - - /// Time when this record was created. - final DateTime time; - - /// Unique sequence number greater than all log records created before it. - final int sequenceNumber; - - static int _nextNumber = 0; - - /// Associated error (if any) when recording errors messages. - final Object error; - - /// Associated stackTrace (if any) when recording errors messages. - final StackTrace stackTrace; - - /// 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, this.object]) - : time = DateTime.now(), - sequenceNumber = LogRecord._nextNumber++; - - @override - String toString() => '[${level.name}] $loggerName: $message'; -} diff --git a/pkgs/logging/lib/src/level.dart b/pkgs/logging/lib/src/level.dart new file mode 100644 index 00000000..b2f7c88f --- /dev/null +++ b/pkgs/logging/lib/src/level.dart @@ -0,0 +1,86 @@ +// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +// 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. + +/// [Level]s to control logging output. Logging can be enabled to include all +/// levels above certain [Level]. [Level]s are ordered using an integer +/// value [Level.value]. The predefined [Level] constants below are sorted as +/// follows (in descending order): [Level.SHOUT], [Level.SEVERE], +/// [Level.WARNING], [Level.INFO], [Level.CONFIG], [Level.FINE], [Level.FINER], +/// [Level.FINEST], and [Level.ALL]. +/// +/// We recommend using one of the predefined logging levels. If you define your +/// own level, make sure you use a value between those used in [Level.ALL] and +/// [Level.OFF]. +class Level implements Comparable { + final String name; + + /// Unique value for this level. Used to order levels, so filtering can + /// exclude messages whose level is under certain value. + final int value; + + const Level(this.name, this.value); + + /// Special key to turn on logging for all levels ([value] = 0). + static const Level ALL = Level('ALL', 0); + + /// Special key to turn off all logging ([value] = 2000). + static const Level OFF = Level('OFF', 2000); + + /// Key for highly detailed tracing ([value] = 300). + static const Level FINEST = Level('FINEST', 300); + + /// Key for fairly detailed tracing ([value] = 400). + static const Level FINER = Level('FINER', 400); + + /// Key for tracing information ([value] = 500). + static const Level FINE = Level('FINE', 500); + + /// Key for static configuration messages ([value] = 700). + static const Level CONFIG = Level('CONFIG', 700); + + /// Key for informational messages ([value] = 800). + static const Level INFO = Level('INFO', 800); + + /// Key for potential problems ([value] = 900). + static const Level WARNING = Level('WARNING', 900); + + /// Key for serious failures ([value] = 1000). + static const Level SEVERE = Level('SEVERE', 1000); + + /// Key for extra debugging loudness ([value] = 1200). + static const Level SHOUT = Level('SHOUT', 1200); + + static const List LEVELS = [ + ALL, + FINEST, + FINER, + FINE, + CONFIG, + INFO, + WARNING, + SEVERE, + SHOUT, + OFF + ]; + + @override + bool operator ==(Object other) => other is Level && value == other.value; + + bool operator <(Level other) => value < other.value; + + bool operator <=(Level other) => value <= other.value; + + bool operator >(Level other) => value > other.value; + + bool operator >=(Level other) => value >= other.value; + + @override + int compareTo(Level other) => value - other.value; + + @override + int get hashCode => value; + + @override + String toString() => name; +} diff --git a/pkgs/logging/lib/src/log_record.dart b/pkgs/logging/lib/src/log_record.dart new file mode 100644 index 00000000..40d934e3 --- /dev/null +++ b/pkgs/logging/lib/src/log_record.dart @@ -0,0 +1,42 @@ +import 'dart:async'; + +import 'level.dart'; +import 'logger.dart'; + +/// A log entry representation used to propagate information from [Logger] to +/// individual handlers. +class LogRecord { + final Level level; + final String message; + + /// Non-string message passed to Logger. + final Object object; + + /// Logger where this record is stored. + final String loggerName; + + /// Time when this record was created. + final DateTime time; + + /// Unique sequence number greater than all log records created before it. + final int sequenceNumber; + + static int _nextNumber = 0; + + /// Associated error (if any) when recording errors messages. + final Object error; + + /// Associated stackTrace (if any) when recording errors messages. + final StackTrace stackTrace; + + /// 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, this.object]) + : time = DateTime.now(), + sequenceNumber = LogRecord._nextNumber++; + + @override + String toString() => '[${level.name}] $loggerName: $message'; +} diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart new file mode 100644 index 00000000..bb71838b --- /dev/null +++ b/pkgs/logging/lib/src/logger.dart @@ -0,0 +1,242 @@ +import 'dart:async'; +import 'dart:collection'; + +import 'level.dart'; +import 'log_record.dart'; + +/// Whether to allow fine-grain logging and configuration of loggers in a +/// hierarchy. +/// +/// When false, all logging is merged in the root logger. +bool hierarchicalLoggingEnabled = false; + +/// Automatically record stack traces for any message of this level or above. +/// +/// Because this is expensive, this is off by default. +Level recordStackTraceAtLevel = Level.OFF; + +/// Level for the root-logger. +/// +/// This will be the level of all loggers if [hierarchicalLoggingEnabled] is +/// false. +Level _rootLevel = Level.INFO; + +/// Use a [Logger] to log debug messages. +/// +/// [Logger]s are named using a hierarchical dot-separated name convention. +class Logger { + /// Simple name of this logger. + final String name; + + /// The full name of this logger, which includes the parent's full name. + String get fullName => + (parent == null || parent.name == '') ? name : '${parent.fullName}.$name'; + + /// Parent of this logger in the hierarchy of loggers. + final Logger parent; + + /// Logging [Level] used for entries generated on this logger. + Level _level; + + final Map _children; + + /// Children in the hierarchy of loggers, indexed by their simple names. + final Map children; + + /// Controller used to notify when log entries are added to this logger. + StreamController _controller; + + /// Singleton constructor. Calling `new Logger(name)` will return the same + /// actual instance whenever it is called with the same string name. + factory Logger(String name) => + _loggers.putIfAbsent(name, () => Logger._named(name)); + + /// Creates a new detached [Logger]. + /// + /// Returns a new [Logger] instance (unlike `new Logger`, which returns a + /// [Logger] singleton), which doesn't have any parent or children, + /// and is not a part of the global hierarchical loggers structure. + /// + /// It can be useful when you just need a local short-living logger, + /// which you'd like to be garbage-collected later. + factory Logger.detached(String name) => + Logger._internal(name, null, {}); + + factory Logger._named(String name) { + if (name.startsWith('.')) { + throw ArgumentError("name shouldn't start with a '.'"); + } + // Split hierarchical names (separated with '.'). + var dot = name.lastIndexOf('.'); + Logger parent; + String thisName; + if (dot == -1) { + if (name != '') parent = Logger(''); + thisName = name; + } else { + parent = Logger(name.substring(0, dot)); + thisName = name.substring(dot + 1); + } + return Logger._internal(thisName, parent, {}); + } + + Logger._internal(this.name, this.parent, Map children) + : _children = children, + children = UnmodifiableMapView(children) { + if (parent != null) parent._children[name] = this; + } + + /// Effective level considering the levels established in this logger's + /// parents (when [hierarchicalLoggingEnabled] is true). + Level get level { + if (hierarchicalLoggingEnabled) { + if (_level != null) return _level; + if (parent != null) return parent.level; + } + return _rootLevel; + } + + /// Override the level for this particular [Logger] and its children. + set level(Level value) { + if (hierarchicalLoggingEnabled && parent != null) { + _level = value; + } else { + if (parent != null) { + throw UnsupportedError( + 'Please set "hierarchicalLoggingEnabled" to true if you want to ' + 'change the level on a non-root logger.'); + } + _rootLevel = value; + } + } + + /// Returns a stream of messages added to this [Logger]. + /// + /// You can listen for messages using the standard stream APIs, for instance: + /// + /// ```dart + /// logger.onRecord.listen((record) { ... }); + /// ``` + Stream get onRecord => _getStream(); + + void clearListeners() { + if (hierarchicalLoggingEnabled || parent == null) { + if (_controller != null) { + _controller.close(); + _controller = null; + } + } else { + root.clearListeners(); + } + } + + /// Whether a message for [value]'s level is loggable in this logger. + bool isLoggable(Level value) => (value >= level); + + /// Adds a log record for a [message] at a particular [logLevel] if + /// `isLoggable(logLevel)` is true. + /// + /// Use this method to create log entries for user-defined levels. To record a + /// message at a predefined level (e.g. [Level.INFO], [Level.WARNING], etc) + /// you can use their specialized methods instead (e.g. [info], [warning], + /// etc). + /// + /// If [message] is a [Function], it will be lazy evaluated. Additionally, if + /// [message] or its evaluated value is not a [String], then 'toString()' will + /// be called on the object and the result will be logged. The log record will + /// contain a field holding the original object. + /// + /// The log record will also contain a field for the zone in which this call + /// was made. This can be advantageous if a log listener wants to handler + /// records of 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]) { + Object object; + if (isLoggable(logLevel)) { + if (message is Function) { + message = message(); + } + + String msg; + if (message is String) { + msg = message; + } else { + msg = message.toString(); + object = message; + } + + if (stackTrace == null && logLevel >= recordStackTraceAtLevel) { + stackTrace = StackTrace.current; + error ??= 'autogenerated stack trace for $logLevel $msg'; + } + zone ??= Zone.current; + + var record = + LogRecord(logLevel, msg, fullName, error, stackTrace, zone, object); + + if (hierarchicalLoggingEnabled) { + var target = this; + while (target != null) { + target._publish(record); + target = target.parent; + } + } else { + root._publish(record); + } + } + } + + /// Log message at level [Level.FINEST]. + void finest(message, [Object error, StackTrace stackTrace]) => + log(Level.FINEST, message, error, stackTrace); + + /// Log message at level [Level.FINER]. + void finer(message, [Object error, StackTrace stackTrace]) => + log(Level.FINER, message, error, stackTrace); + + /// Log message at level [Level.FINE]. + void fine(message, [Object error, StackTrace stackTrace]) => + log(Level.FINE, message, error, stackTrace); + + /// Log message at level [Level.CONFIG]. + void config(message, [Object error, StackTrace stackTrace]) => + log(Level.CONFIG, message, error, stackTrace); + + /// Log message at level [Level.INFO]. + void info(message, [Object error, StackTrace stackTrace]) => + log(Level.INFO, message, error, stackTrace); + + /// Log message at level [Level.WARNING]. + void warning(message, [Object error, StackTrace stackTrace]) => + log(Level.WARNING, message, error, stackTrace); + + /// Log message at level [Level.SEVERE]. + void severe(message, [Object error, StackTrace stackTrace]) => + log(Level.SEVERE, message, error, stackTrace); + + /// Log message at level [Level.SHOUT]. + void shout(message, [Object error, StackTrace stackTrace]) => + log(Level.SHOUT, message, error, stackTrace); + + Stream _getStream() { + if (hierarchicalLoggingEnabled || parent == null) { + _controller ??= StreamController.broadcast(sync: true); + return _controller.stream; + } else { + return root._getStream(); + } + } + + void _publish(LogRecord record) { + if (_controller != null) { + _controller.add(record); + } + } + + /// Top-level root [Logger]. + static final Logger root = Logger(''); + + /// All [Logger]s in the system. + static final Map _loggers = {}; +} From 0db7a0701733ad2ae388d3dff462c9b392452bab Mon Sep 17 00:00:00 2001 From: "James D. Lin" Date: Fri, 10 Jan 2020 15:37:51 -0800 Subject: [PATCH 098/163] Replace _rootLevel with root._level (dart-lang/logging#69) Previously root._level and _rootLevel both existed and could be different. The existing code took care to always use _rootLevel instead of root._level, but I think it'd be better to not have the extra Level variable at all. This also provides an opportunity to expose a public constant for the the default logging level, further addressing https://github.com/dart-lang/logging/issues/57. --- pkgs/logging/lib/src/logger.dart | 19 +++++++++---------- pkgs/logging/test/logging_test.dart | 6 ++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index bb71838b..a34df505 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -7,7 +7,7 @@ import 'log_record.dart'; /// Whether to allow fine-grain logging and configuration of loggers in a /// hierarchy. /// -/// When false, all logging is merged in the root logger. +/// When false, all hierarchical logging instead is merged in the root logger. bool hierarchicalLoggingEnabled = false; /// Automatically record stack traces for any message of this level or above. @@ -15,11 +15,8 @@ bool hierarchicalLoggingEnabled = false; /// Because this is expensive, this is off by default. Level recordStackTraceAtLevel = Level.OFF; -/// Level for the root-logger. -/// -/// This will be the level of all loggers if [hierarchicalLoggingEnabled] is -/// false. -Level _rootLevel = Level.INFO; +/// The default [Level]. +const defaultLevel = Level.INFO; /// Use a [Logger] to log debug messages. /// @@ -83,7 +80,9 @@ class Logger { Logger._internal(this.name, this.parent, Map children) : _children = children, children = UnmodifiableMapView(children) { - if (parent != null) parent._children[name] = this; + if (parent != null) { + parent._children[name] = this; + } } /// Effective level considering the levels established in this logger's @@ -93,7 +92,7 @@ class Logger { if (_level != null) return _level; if (parent != null) return parent.level; } - return _rootLevel; + return root._level; } /// Override the level for this particular [Logger] and its children. @@ -106,7 +105,7 @@ class Logger { 'Please set "hierarchicalLoggingEnabled" to true if you want to ' 'change the level on a non-root logger.'); } - _rootLevel = value; + root._level = value; } } @@ -235,7 +234,7 @@ class Logger { } /// Top-level root [Logger]. - static final Logger root = Logger(''); + static final Logger root = Logger('').._level = defaultLevel; /// All [Logger]s in the system. static final Map _loggers = {}; diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index b24a8a99..53fbf4e8 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -73,6 +73,12 @@ void main() { expect(() => Logger('.c'), throwsArgumentError); }); + test('root level has proper defaults', () { + expect(Logger.root, isNotNull); + expect(Logger.root.parent, null); + expect(Logger.root.level, defaultLevel); + }); + test('logger naming is hierarchical', () { var c = Logger('a.b.c'); expect(c.name, equals('c')); From 14084f1a8ebbc82ade791754c5aceaf664b86543 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 10 Jan 2020 16:40:35 -0800 Subject: [PATCH 099/163] Add changelog entry for defaultLevel (dart-lang/logging#70) --- pkgs/logging/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 3017f898..0b9bc10c 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,5 +1,6 @@ -## 0.11.4 +## 0.11.4-dev +* Add top level `defaultLevel`. * Require Dart `>=2.0.0`. ## 0.11.3+2 From fbe62b441b64ccfa47446a91a1c9863326978e8f Mon Sep 17 00:00:00 2001 From: "James D. Lin" Date: Wed, 15 Jan 2020 10:12:26 -0800 Subject: [PATCH 100/163] Make detached Loggers work regardless of hierarchicalLoggingEnabled (dart-lang/logging#71) Previously detached Loggers could log messages only if hierarchicalLoggingEnabled was true. This makes no sense to me since detached Loggers aren't part of a Logger hierarchy. Fixes https://github.com/dart-lang/logging/issues/34. --- pkgs/logging/CHANGELOG.md | 3 +- pkgs/logging/lib/src/logger.dart | 45 ++++++++++++--------- pkgs/logging/test/logging_test.dart | 62 +++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 19 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 0b9bc10c..adca9edc 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -2,6 +2,7 @@ * Add top level `defaultLevel`. * Require Dart `>=2.0.0`. +* Make detached loggers work regardless of `hierarchicalLoggingEnabled`. ## 0.11.3+2 @@ -21,7 +22,7 @@ ## 0.11.2 -* Added Logger.detached - a convenience factory to obtain a logger that is not +* Added `Logger.detached` - a convenience factory to obtain a logger that is not attached to this library's logger hierarchy. ## 0.11.1+1 diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index a34df505..b94f034c 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -80,7 +80,9 @@ class Logger { Logger._internal(this.name, this.parent, Map children) : _children = children, children = UnmodifiableMapView(children) { - if (parent != null) { + if (parent == null) { + _level = defaultLevel; + } else { parent._children[name] = this; } } @@ -88,25 +90,30 @@ class Logger { /// Effective level considering the levels established in this logger's /// parents (when [hierarchicalLoggingEnabled] is true). Level get level { - if (hierarchicalLoggingEnabled) { - if (_level != null) return _level; - if (parent != null) return parent.level; + Level effectiveLevel; + + if (parent == null) { + // We're either the root logger or a detached logger. Return our own + // level. + effectiveLevel = _level; + } else if (!hierarchicalLoggingEnabled) { + effectiveLevel = root._level; + } else { + effectiveLevel = _level ?? parent.level; } - return root._level; + + assert(effectiveLevel != null); + return effectiveLevel; } /// Override the level for this particular [Logger] and its children. set level(Level value) { - if (hierarchicalLoggingEnabled && parent != null) { - _level = value; - } else { - if (parent != null) { - throw UnsupportedError( - 'Please set "hierarchicalLoggingEnabled" to true if you want to ' - 'change the level on a non-root logger.'); - } - root._level = value; + if (!hierarchicalLoggingEnabled && parent != null) { + throw UnsupportedError( + 'Please set "hierarchicalLoggingEnabled" to true if you want to ' + 'change the level on a non-root logger.'); } + _level = value; } /// Returns a stream of messages added to this [Logger]. @@ -174,14 +181,16 @@ class Logger { var record = LogRecord(logLevel, msg, fullName, error, stackTrace, zone, object); - if (hierarchicalLoggingEnabled) { + if (parent == null) { + _publish(record); + } else if (!hierarchicalLoggingEnabled) { + root._publish(record); + } else { var target = this; while (target != null) { target._publish(record); target = target.parent; } - } else { - root._publish(record); } } } @@ -234,7 +243,7 @@ class Logger { } /// Top-level root [Logger]. - static final Logger root = Logger('').._level = defaultLevel; + static final Logger root = Logger(''); /// All [Logger]s in the system. static final Map _loggers = {}; diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 53fbf4e8..d0af49c0 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -10,6 +10,8 @@ import 'package:logging/logging.dart'; import 'package:test/test.dart'; void main() { + final hierarchicalLoggingEnabledDefault = hierarchicalLoggingEnabled; + test('level comparison is a valid comparator', () { var level1 = const Level('NOT_REAL1', 253); expect(level1 == level1, isTrue); @@ -213,6 +215,11 @@ void main() { }); group('detached loggers', () { + tearDown(() { + hierarchicalLoggingEnabled = hierarchicalLoggingEnabledDefault; + Logger.root.level = defaultLevel; + }); + test('create new instances of Logger', () { var a1 = Logger.detached('a'); var a2 = Logger.detached('a'); @@ -232,6 +239,51 @@ void main() { var a = Logger.detached('a'); expect(a.children, {}); }); + + test('have levels independent of the root level', () { + void testDetachedLoggerLevel(bool withHierarchy) { + hierarchicalLoggingEnabled = withHierarchy; + + const newRootLevel = Level.ALL; + const newDetachedLevel = Level.OFF; + + Logger.root.level = newRootLevel; + + final detached = Logger.detached('a'); + expect(detached.level, defaultLevel); + expect(Logger.root.level, newRootLevel); + + detached.level = newDetachedLevel; + expect(detached.level, newDetachedLevel); + expect(Logger.root.level, newRootLevel); + } + + testDetachedLoggerLevel(false); + testDetachedLoggerLevel(true); + }); + + test('log messages regardless of hierarchy', () { + void testDetachedLoggerOnRecord(bool withHierarchy) { + var calls = 0; + void handler(_) => calls += 1; + + hierarchicalLoggingEnabled = withHierarchy; + + final detached = Logger.detached('a'); + detached.level = Level.ALL; + detached.onRecord.listen(handler); + + Logger.root.info('foo'); + expect(calls, 0); + + detached.info('foo'); + detached.info('foo'); + expect(calls, 2); + } + + testDetachedLoggerOnRecord(false); + testDetachedLoggerOnRecord(true); + }); }); group('mutating levels', () { @@ -294,6 +346,16 @@ void main() { expect(c.level, equals(Level.FINE)); }); + test('loggers effective level - with changing hierarchy', () { + hierarchicalLoggingEnabled = true; + d.level = Level.SHOUT; + hierarchicalLoggingEnabled = false; + + expect(root.level, Level.INFO); + expect(d.level, root.level); + expect(e.level, root.level); + }); + test('isLoggable is appropriate', () { hierarchicalLoggingEnabled = true; root.level = Level.SEVERE; From 980b9ee7fab23165d2c94208cf52a355cc7a4a26 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Thu, 16 Jan 2020 10:22:43 -0800 Subject: [PATCH 101/163] prepare to release 0.11.4 (dart-lang/logging#72) --- pkgs/logging/CHANGELOG.md | 2 +- pkgs/logging/pubspec.yaml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index adca9edc..9bbd99d8 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.11.4-dev +## 0.11.4 * Add top level `defaultLevel`. * Require Dart `>=2.0.0`. diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 9eba1879..83688a9c 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,11 +1,10 @@ name: logging -version: 0.11.4-dev +version: 0.11.4 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. -author: Dart Team homepage: https://github.com/dart-lang/logging environment: From a8750ab740ae886d9b760c1e9fd67b62e787bcae Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 11 Mar 2020 17:54:06 -0700 Subject: [PATCH 102/163] Reference docs for message arguments (dart-lang/logging#77) Closes dart-lang/logging#31 Link to the `log` method which has a more detailed description of how non String `message` arguments are handled. --- pkgs/logging/CHANGELOG.md | 2 ++ pkgs/logging/lib/src/logger.dart | 24 ++++++++++++++++++++++++ pkgs/logging/pubspec.yaml | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 9bbd99d8..0c465e22 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.11.5-dev + ## 0.11.4 * Add top level `defaultLevel`. diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index b94f034c..7b36ab10 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -196,34 +196,58 @@ class Logger { } /// Log message at level [Level.FINEST]. + /// + /// See [log] for information on how non-String [message] arguments are + /// handeled. void finest(message, [Object error, StackTrace stackTrace]) => log(Level.FINEST, message, error, stackTrace); /// Log message at level [Level.FINER]. + /// + /// See [log] for information on how non-String [message] arguments are + /// handeled. void finer(message, [Object error, StackTrace stackTrace]) => log(Level.FINER, message, error, stackTrace); /// Log message at level [Level.FINE]. + /// + /// See [log] for information on how non-String [message] arguments are + /// handeled. void fine(message, [Object error, StackTrace stackTrace]) => log(Level.FINE, message, error, stackTrace); /// Log message at level [Level.CONFIG]. + /// + /// See [log] for information on how non-String [message] arguments are + /// handeled. void config(message, [Object error, StackTrace stackTrace]) => log(Level.CONFIG, message, error, stackTrace); /// Log message at level [Level.INFO]. + /// + /// See [log] for information on how non-String [message] arguments are + /// handeled. void info(message, [Object error, StackTrace stackTrace]) => log(Level.INFO, message, error, stackTrace); /// Log message at level [Level.WARNING]. + /// + /// See [log] for information on how non-String [message] arguments are + /// handeled. void warning(message, [Object error, StackTrace stackTrace]) => log(Level.WARNING, message, error, stackTrace); /// Log message at level [Level.SEVERE]. + /// + /// See [log] for information on how non-String [message] arguments are + /// handeled. void severe(message, [Object error, StackTrace stackTrace]) => log(Level.SEVERE, message, error, stackTrace); /// Log message at level [Level.SHOUT]. + /// + /// See [log] for information on how non-String [message] arguments are + /// handeled. void shout(message, [Object error, StackTrace stackTrace]) => log(Level.SHOUT, message, error, stackTrace); diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 83688a9c..9a0a6eaa 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 0.11.4 +version: 0.11.5-dev description: >- Provides APIs for debugging and error logging. This library introduces From 013f6c0022fa1cb2d7fbd7bdcff75c88b50ad56e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 28 Jul 2020 20:32:38 -0700 Subject: [PATCH 103/163] Delete .test_config No longer used --- pkgs/logging/.test_config | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 pkgs/logging/.test_config diff --git a/pkgs/logging/.test_config b/pkgs/logging/.test_config deleted file mode 100644 index 412fc5c5..00000000 --- a/pkgs/logging/.test_config +++ /dev/null @@ -1,3 +0,0 @@ -{ - "test_package": true -} \ No newline at end of file From 835044273764d4e8245f0ab7fa1e6e59c76d13db Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 28 Aug 2020 08:28:07 -0700 Subject: [PATCH 104/163] Migrate to null safety (dart-lang/logging#82) --- pkgs/logging/.travis.yml | 39 ++++++++++----- pkgs/logging/CHANGELOG.md | 4 +- pkgs/logging/analysis_options.yaml | 2 + pkgs/logging/lib/src/log_record.dart | 8 +-- pkgs/logging/lib/src/logger.dart | 75 ++++++++++++++++------------ pkgs/logging/pubspec.yaml | 16 ++++-- pkgs/logging/test/logging_test.dart | 36 +++++++------ 7 files changed, 110 insertions(+), 70 deletions(-) diff --git a/pkgs/logging/.travis.yml b/pkgs/logging/.travis.yml index cb069312..f3fbea25 100644 --- a/pkgs/logging/.travis.yml +++ b/pkgs/logging/.travis.yml @@ -1,23 +1,36 @@ language: dart dart: - - dev - - 2.0.0 +- dev -dart_task: - - test: --platform vm - - test: --platform chrome - - dartanalyzer: --fatal-infos --fatal-warnings . - -matrix: +jobs: include: - - dart: dev - dart_task: dartfmt + - stage: analyze_and_format + name: "Analyze" + os: linux + script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos . + - stage: analyze_and_format + name: "Format" + os: linux + script: dartfmt -n --set-exit-if-changed . + - stage: test + name: "Vm Tests" + os: linux + script: pub run --enable-experiment=non-nullable test -p vm + - stage: test + name: "Web Tests" + os: linux + script: pub run --enable-experiment=non-nullable test -p chrome + +stages: + - analyze_and_format + - test # Only building master means that we don't run two builds for each pull request. branches: - only: [master] + only: [master, null_safety] +# Incremental pub cache and builds. cache: - directories: - - $HOME/.pub-cache + directories: + - $HOME/.pub-cache diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 0c465e22..badb6de9 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,4 +1,6 @@ -## 0.11.5-dev +## 1.0.0-dev + +* Migrate to null safety. ## 0.11.4 diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index fbe6079f..c7126cab 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -7,6 +7,8 @@ analyzer: unused_import: error unused_local_variable: error dead_code: error + enable-experiment: + - non-nullable linter: rules: - annotate_overrides diff --git a/pkgs/logging/lib/src/log_record.dart b/pkgs/logging/lib/src/log_record.dart index 40d934e3..c1df3580 100644 --- a/pkgs/logging/lib/src/log_record.dart +++ b/pkgs/logging/lib/src/log_record.dart @@ -10,7 +10,7 @@ class LogRecord { final String message; /// Non-string message passed to Logger. - final Object object; + final Object? object; /// Logger where this record is stored. final String loggerName; @@ -24,13 +24,13 @@ class LogRecord { static int _nextNumber = 0; /// Associated error (if any) when recording errors messages. - final Object error; + final Object? error; /// Associated stackTrace (if any) when recording errors messages. - final StackTrace stackTrace; + final StackTrace? stackTrace; /// Zone of the calling code which resulted in this LogRecord. - final Zone zone; + final Zone? zone; LogRecord(this.level, this.message, this.loggerName, [this.error, this.stackTrace, this.zone, this.object]) diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index 7b36ab10..a2bc0757 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -27,21 +27,29 @@ class Logger { /// The full name of this logger, which includes the parent's full name. String get fullName => - (parent == null || parent.name == '') ? name : '${parent.fullName}.$name'; + parent?.name.isNotEmpty ?? false ? '${parent!.fullName}.$name' : name; /// Parent of this logger in the hierarchy of loggers. - final Logger parent; + final Logger? parent; /// Logging [Level] used for entries generated on this logger. - Level _level; + /// + /// Only the root logger is guaranteed to have a non-null [Level]. + Level? _level; + /// Private modifiable map of child loggers, indexed by their simple names. final Map _children; /// Children in the hierarchy of loggers, indexed by their simple names. + /// + /// This is an unmodifiable map. final Map children; /// Controller used to notify when log entries are added to this logger. - StreamController _controller; + /// + /// If heirarchical logging is disabled then this is `null` for all but the + /// root [Logger]. + StreamController? _controller; /// Singleton constructor. Calling `new Logger(name)` will return the same /// actual instance whenever it is called with the same string name. @@ -65,7 +73,7 @@ class Logger { } // Split hierarchical names (separated with '.'). var dot = name.lastIndexOf('.'); - Logger parent; + Logger? parent; String thisName; if (dot == -1) { if (name != '') parent = Logger(''); @@ -83,7 +91,7 @@ class Logger { if (parent == null) { _level = defaultLevel; } else { - parent._children[name] = this; + parent!._children[name] = this; } } @@ -95,24 +103,31 @@ class Logger { if (parent == null) { // We're either the root logger or a detached logger. Return our own // level. - effectiveLevel = _level; + effectiveLevel = _level!; } else if (!hierarchicalLoggingEnabled) { - effectiveLevel = root._level; + effectiveLevel = root._level!; } else { - effectiveLevel = _level ?? parent.level; + effectiveLevel = _level ?? parent!.level; } + // ignore: unnecessary_null_comparison assert(effectiveLevel != null); return effectiveLevel; } /// Override the level for this particular [Logger] and its children. - set level(Level value) { + /// + /// Setting this to `null` makes it inherit the [parent]s level. + set level(Level? value) { if (!hierarchicalLoggingEnabled && parent != null) { throw UnsupportedError( 'Please set "hierarchicalLoggingEnabled" to true if you want to ' 'change the level on a non-root logger.'); } + if (parent == null && value == null) { + throw UnsupportedError( + 'Cannot set the level to `null` on a logger with no parent.'); + } _level = value; } @@ -127,10 +142,8 @@ class Logger { void clearListeners() { if (hierarchicalLoggingEnabled || parent == null) { - if (_controller != null) { - _controller.close(); - _controller = null; - } + _controller?.close(); + _controller = null; } else { root.clearListeners(); } @@ -156,9 +169,9 @@ class Logger { /// was made. This can be advantageous if a log listener wants to handler /// records of 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]) { - Object object; + void log(Level logLevel, Object? message, + [Object? error, StackTrace? stackTrace, Zone? zone]) { + Object? object; if (isLoggable(logLevel)) { if (message is Function) { message = message(); @@ -186,7 +199,7 @@ class Logger { } else if (!hierarchicalLoggingEnabled) { root._publish(record); } else { - var target = this; + Logger? target = this; while (target != null) { target._publish(record); target = target.parent; @@ -199,72 +212,68 @@ class Logger { /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void finest(message, [Object error, StackTrace stackTrace]) => + void finest(message, [Object? error, StackTrace? stackTrace]) => log(Level.FINEST, message, error, stackTrace); /// Log message at level [Level.FINER]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void finer(message, [Object error, StackTrace stackTrace]) => + void finer(message, [Object? error, StackTrace? stackTrace]) => log(Level.FINER, message, error, stackTrace); /// Log message at level [Level.FINE]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void fine(message, [Object error, StackTrace stackTrace]) => + void fine(message, [Object? error, StackTrace? stackTrace]) => log(Level.FINE, message, error, stackTrace); /// Log message at level [Level.CONFIG]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void config(message, [Object error, StackTrace stackTrace]) => + void config(message, [Object? error, StackTrace? stackTrace]) => log(Level.CONFIG, message, error, stackTrace); /// Log message at level [Level.INFO]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void info(message, [Object error, StackTrace stackTrace]) => + void info(message, [Object? error, StackTrace? stackTrace]) => log(Level.INFO, message, error, stackTrace); /// Log message at level [Level.WARNING]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void warning(message, [Object error, StackTrace stackTrace]) => + void warning(message, [Object? error, StackTrace? stackTrace]) => log(Level.WARNING, message, error, stackTrace); /// Log message at level [Level.SEVERE]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void severe(message, [Object error, StackTrace stackTrace]) => + void severe(message, [Object? error, StackTrace? stackTrace]) => log(Level.SEVERE, message, error, stackTrace); /// Log message at level [Level.SHOUT]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void shout(message, [Object error, StackTrace stackTrace]) => + void shout(message, [Object? error, StackTrace? stackTrace]) => log(Level.SHOUT, message, error, stackTrace); Stream _getStream() { if (hierarchicalLoggingEnabled || parent == null) { - _controller ??= StreamController.broadcast(sync: true); - return _controller.stream; + return (_controller ??= StreamController.broadcast(sync: true)) + .stream; } else { return root._getStream(); } } - void _publish(LogRecord record) { - if (_controller != null) { - _controller.add(record); - } - } + void _publish(LogRecord record) => _controller?.add(record); /// Top-level root [Logger]. static final Logger root = Logger(''); diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 9a0a6eaa..e718af41 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,15 +1,23 @@ name: logging -version: 0.11.5-dev +version: 1.0.0-dev 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: https://github.com/dart-lang/logging +# This package requires the unreleased null safety feature, and cannot be +# published until that ships. +publish_to: none environment: - sdk: '>=2.0.0 <3.0.0' + sdk: '>=2.10.0-0.0 <2.10.0' dev_dependencies: - pedantic: ^1.3.0 - test: ^1.3.0 + pedantic: ^1.10.0-nullsafety + test: ^1.16.0-nullsafety + +dependency_overrides: + # These are required to get a version solve since they depend on this package + coverage: ^0.13.3 + webkit_inspection_protocol: ^0.5.0 diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index d0af49c0..a0c705f3 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -84,19 +84,19 @@ void main() { test('logger naming is hierarchical', () { var c = Logger('a.b.c'); expect(c.name, equals('c')); - expect(c.parent.name, equals('b')); - expect(c.parent.parent.name, equals('a')); - expect(c.parent.parent.parent.name, equals('')); - expect(c.parent.parent.parent.parent, isNull); + expect(c.parent!.name, equals('b')); + expect(c.parent!.parent!.name, equals('a')); + expect(c.parent!.parent!.parent!.name, equals('')); + expect(c.parent!.parent!.parent!.parent, isNull); }); test('logger full name', () { var c = Logger('a.b.c'); expect(c.fullName, equals('a.b.c')); - expect(c.parent.fullName, equals('a.b')); - expect(c.parent.parent.fullName, equals('a')); - expect(c.parent.parent.parent.fullName, equals('')); - expect(c.parent.parent.parent.parent, isNull); + expect(c.parent!.fullName, equals('a.b')); + expect(c.parent!.parent!.fullName, equals('a')); + expect(c.parent!.parent!.parent!.fullName, equals('')); + expect(c.parent!.parent!.parent!.parent, isNull); }); test('logger parent-child links are correct', () { @@ -122,12 +122,12 @@ void main() { test('cannot directly manipulate Logger.children', () { var loggerAB = Logger('a.b'); - var loggerA = loggerAB.parent; + var loggerA = loggerAB.parent!; expect(loggerA.children['b'], same(loggerAB), reason: 'can read Children'); expect(() { - loggerAB.children['test'] = null; + loggerAB.children['test'] = Logger('Fake1234'); }, throwsUnsupportedError, reason: 'Children is read-only'); }); @@ -183,7 +183,7 @@ void main() { test('child zone', () { var root = Logger.root; - Zone recordingZone; + late Zone recordingZone; var records = []; root.onRecord.listen(records.add); @@ -199,7 +199,7 @@ void main() { test('custom zone', () { var root = Logger.root; - Zone recordingZone; + late Zone recordingZone; var records = []; root.onRecord.listen(records.add); @@ -313,9 +313,15 @@ void main() { }); test('cannot set level if hierarchy is disabled', () { - expect(() { - a.level = Level.FINE; - }, throwsUnsupportedError); + expect(() => a.level = Level.FINE, throwsUnsupportedError); + }); + + test('cannot set the level to null on the root logger', () { + expect(() => root.level = null, throwsUnsupportedError); + }); + + test('cannot set the level to null on a detached logger', () { + expect(() => Logger.detached('l').level = null, throwsUnsupportedError); }); test('loggers effective level - no hierarchy', () { From a7656b16c37be28c9ff0aa05cc9481999b80877e Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 29 Sep 2020 10:51:00 -0700 Subject: [PATCH 105/163] update sdk constraint to allow 2.11 dev (dart-lang/logging#84) --- pkgs/logging/.travis.yml | 2 +- pkgs/logging/CHANGELOG.md | 2 +- pkgs/logging/pubspec.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/logging/.travis.yml b/pkgs/logging/.travis.yml index f3fbea25..4cc3a6a7 100644 --- a/pkgs/logging/.travis.yml +++ b/pkgs/logging/.travis.yml @@ -28,7 +28,7 @@ stages: # Only building master means that we don't run two builds for each pull request. branches: - only: [master, null_safety] + only: [master] # Incremental pub cache and builds. cache: diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index badb6de9..e762ceb5 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.0.0-dev +## 1.0.0-nullsafety-dev * Migrate to null safety. diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index e718af41..3cc2b216 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.0.0-dev +version: 1.0.0-nullsafety-dev description: >- Provides APIs for debugging and error logging. This library introduces @@ -11,7 +11,7 @@ homepage: https://github.com/dart-lang/logging publish_to: none environment: - sdk: '>=2.10.0-0.0 <2.10.0' + sdk: '>=2.10.0-0.0 <2.11.0' dev_dependencies: pedantic: ^1.10.0-nullsafety From 66eee208c4b65da5962031e51cc6ec07379b64b2 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 3 Nov 2020 07:18:08 -0800 Subject: [PATCH 106/163] Support Dart 2.11 (dart-lang/logging#85) --- pkgs/logging/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 3cc2b216..867f8d31 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -11,7 +11,7 @@ homepage: https://github.com/dart-lang/logging publish_to: none environment: - sdk: '>=2.10.0-0.0 <2.11.0' + sdk: '>=2.10.0-0.0 <2.12.0' dev_dependencies: pedantic: ^1.10.0-nullsafety From f4f0b4cff9ec1818ab215051194b05413fd3c7b6 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 10 Nov 2020 09:33:26 -0800 Subject: [PATCH 107/163] final cleanup, prep null safety release (dart-lang/logging#86) --- pkgs/logging/CHANGELOG.md | 3 ++- pkgs/logging/lib/logging.dart | 7 ------- pkgs/logging/lib/src/logger.dart | 16 ++++++++-------- pkgs/logging/pubspec.yaml | 4 ++-- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index e762ceb5..c22632c8 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,6 +1,7 @@ -## 1.0.0-nullsafety-dev +## 1.0.0-nullsafety.0 * Migrate to null safety. +* Removed the deprecated `LoggerHandler` typedef. ## 0.11.4 diff --git a/pkgs/logging/lib/logging.dart b/pkgs/logging/lib/logging.dart index f84bbb1a..6f447e7c 100644 --- a/pkgs/logging/lib/logging.dart +++ b/pkgs/logging/lib/logging.dart @@ -2,13 +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. -import 'src/log_record.dart'; -import 'src/logger.dart'; - export 'src/level.dart'; export 'src/log_record.dart'; export 'src/logger.dart'; - -/// Handler callback to process log entries as they are added to a [Logger]. -@Deprecated('Will be removed in 1.0.0') -typedef LoggerHandler = void Function(LogRecord record); diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index a2bc0757..e110d982 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -212,56 +212,56 @@ class Logger { /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void finest(message, [Object? error, StackTrace? stackTrace]) => + void finest(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.FINEST, message, error, stackTrace); /// Log message at level [Level.FINER]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void finer(message, [Object? error, StackTrace? stackTrace]) => + void finer(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.FINER, message, error, stackTrace); /// Log message at level [Level.FINE]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void fine(message, [Object? error, StackTrace? stackTrace]) => + void fine(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.FINE, message, error, stackTrace); /// Log message at level [Level.CONFIG]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void config(message, [Object? error, StackTrace? stackTrace]) => + void config(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.CONFIG, message, error, stackTrace); /// Log message at level [Level.INFO]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void info(message, [Object? error, StackTrace? stackTrace]) => + void info(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.INFO, message, error, stackTrace); /// Log message at level [Level.WARNING]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void warning(message, [Object? error, StackTrace? stackTrace]) => + void warning(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.WARNING, message, error, stackTrace); /// Log message at level [Level.SEVERE]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void severe(message, [Object? error, StackTrace? stackTrace]) => + void severe(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.SEVERE, message, error, stackTrace); /// Log message at level [Level.SHOUT]. /// /// See [log] for information on how non-String [message] arguments are /// handeled. - void shout(message, [Object? error, StackTrace? stackTrace]) => + void shout(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.SHOUT, message, error, stackTrace); Stream _getStream() { diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 867f8d31..d7187da9 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.0.0-nullsafety-dev +version: 1.0.0-nullsafety.0 description: >- Provides APIs for debugging and error logging. This library introduces @@ -11,7 +11,7 @@ homepage: https://github.com/dart-lang/logging publish_to: none environment: - sdk: '>=2.10.0-0.0 <2.12.0' + sdk: '>=2.12.0-0 <3.0.0' dev_dependencies: pedantic: ^1.10.0-nullsafety From 73005cc51bf56391219abd5268e905d2eda0a9aa Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Wed, 11 Nov 2020 09:13:24 -0800 Subject: [PATCH 108/163] typos (dart-lang/logging#87) --- pkgs/logging/lib/src/logger.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index e110d982..b298b77a 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -47,7 +47,7 @@ class Logger { /// Controller used to notify when log entries are added to this logger. /// - /// If heirarchical logging is disabled then this is `null` for all but the + /// If hierarchical logging is disabled then this is `null` for all but the /// root [Logger]. StreamController? _controller; @@ -211,56 +211,56 @@ class Logger { /// Log message at level [Level.FINEST]. /// /// See [log] for information on how non-String [message] arguments are - /// handeled. + /// handled. void finest(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.FINEST, message, error, stackTrace); /// Log message at level [Level.FINER]. /// /// See [log] for information on how non-String [message] arguments are - /// handeled. + /// handled. void finer(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.FINER, message, error, stackTrace); /// Log message at level [Level.FINE]. /// /// See [log] for information on how non-String [message] arguments are - /// handeled. + /// handled. void fine(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.FINE, message, error, stackTrace); /// Log message at level [Level.CONFIG]. /// /// See [log] for information on how non-String [message] arguments are - /// handeled. + /// handled. void config(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.CONFIG, message, error, stackTrace); /// Log message at level [Level.INFO]. /// /// See [log] for information on how non-String [message] arguments are - /// handeled. + /// handled. void info(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.INFO, message, error, stackTrace); /// Log message at level [Level.WARNING]. /// /// See [log] for information on how non-String [message] arguments are - /// handeled. + /// handled. void warning(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.WARNING, message, error, stackTrace); /// Log message at level [Level.SEVERE]. /// /// See [log] for information on how non-String [message] arguments are - /// handeled. + /// handled. void severe(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.SEVERE, message, error, stackTrace); /// Log message at level [Level.SHOUT]. /// /// See [log] for information on how non-String [message] arguments are - /// handeled. + /// handled. void shout(Object? message, [Object? error, StackTrace? stackTrace]) => log(Level.SHOUT, message, error, stackTrace); From 979df4f80b4a72a3e19e167279f7ca90566000db Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Wed, 11 Nov 2020 09:14:06 -0800 Subject: [PATCH 109/163] remove redundant experiment (dart-lang/logging#88) --- pkgs/logging/analysis_options.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index c7126cab..fbe6079f 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -7,8 +7,6 @@ analyzer: unused_import: error unused_local_variable: error dead_code: error - enable-experiment: - - non-nullable linter: rules: - annotate_overrides From e1a5df480213a98ffdec7052543f8705b839b9fa Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Mon, 16 Nov 2020 13:03:45 -0800 Subject: [PATCH 110/163] remove publish_to: none (dart-lang/logging#90) --- pkgs/logging/pubspec.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index d7187da9..25a8cb36 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -6,9 +6,6 @@ description: >- abstractions similar to those used in other languages, such as the Closure JS Logger and java.util.logging.Logger. homepage: https://github.com/dart-lang/logging -# This package requires the unreleased null safety feature, and cannot be -# published until that ships. -publish_to: none environment: sdk: '>=2.12.0-0 <3.0.0' From 95e33aab35e50b9fb2b872ba074cd6dbcdda4f84 Mon Sep 17 00:00:00 2001 From: Alexander Thomas Date: Mon, 1 Feb 2021 17:46:49 +0100 Subject: [PATCH 111/163] Migrate to GitHub Actions (dart-lang/logging#94) * Migrate to GitHub Actions * Delete .travis.yml * Replace Travis badge --- .../.github/workflows/test-package.yml | 64 +++++++++++++++++++ pkgs/logging/.travis.yml | 36 ----------- pkgs/logging/README.md | 2 +- 3 files changed, 65 insertions(+), 37 deletions(-) create mode 100644 pkgs/logging/.github/workflows/test-package.yml delete mode 100644 pkgs/logging/.travis.yml diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml new file mode 100644 index 00000000..0a2a8743 --- /dev/null +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -0,0 +1,64 @@ +name: Dart CI + +on: + # Run on PRs and pushes to the default branch. + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: "0 0 * * 0" + +env: + PUB_ENVIRONMENT: bot.github + +jobs: + # Check code formatting and static analysis on a single OS (linux) + # against Dart dev. + analyze: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdk: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.3 + 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 consisting of two dimensions: + # 1. OS: ubuntu-latest, (macos-latest, windows-latest) + # 2. release channel: dev + 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: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.3 + 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' diff --git a/pkgs/logging/.travis.yml b/pkgs/logging/.travis.yml deleted file mode 100644 index 4cc3a6a7..00000000 --- a/pkgs/logging/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -language: dart - -dart: -- dev - -jobs: - include: - - stage: analyze_and_format - name: "Analyze" - os: linux - script: dartanalyzer --enable-experiment=non-nullable --fatal-warnings --fatal-infos . - - stage: analyze_and_format - name: "Format" - os: linux - script: dartfmt -n --set-exit-if-changed . - - stage: test - name: "Vm Tests" - os: linux - script: pub run --enable-experiment=non-nullable test -p vm - - stage: test - name: "Web Tests" - os: linux - script: pub run --enable-experiment=non-nullable test -p chrome - -stages: - - analyze_and_format - - test - -# Only building master means that we don't run two builds for each pull request. -branches: - only: [master] - -# Incremental pub cache and builds. -cache: - directories: - - $HOME/.pub-cache diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index fe2ef543..66ab3166 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/dart-lang/logging.svg?branch=master)](https://travis-ci.org/dart-lang/logging) +[![Build Status](https://github.com/dart-lang/logging/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/logging/actions?query=workflow%3A"Dart+CI"+branch%3Amaster) [![Pub](https://img.shields.io/pub/v/logging.svg)](https://pub.dev/packages/logging) ## Initializing From 1d474a46c06f521ab45e374f132fb3edc01acec7 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 5 Feb 2021 10:58:22 -0800 Subject: [PATCH 112/163] stable null safety release (dart-lang/logging#95) --- pkgs/logging/CHANGELOG.md | 4 ++++ pkgs/logging/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index c22632c8..940d1bf0 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.0 + +* Stable null safety release. + ## 1.0.0-nullsafety.0 * Migrate to null safety. diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 25a8cb36..4273c4ea 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.0.0-nullsafety.0 +version: 1.0.0 description: >- Provides APIs for debugging and error logging. This library introduces @@ -11,7 +11,7 @@ environment: sdk: '>=2.12.0-0 <3.0.0' dev_dependencies: - pedantic: ^1.10.0-nullsafety + pedantic: ^1.10.0 test: ^1.16.0-nullsafety dependency_overrides: From 37bdd568bbb70193027756ecf5e80316879422f1 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 25 Mar 2021 11:04:09 -0700 Subject: [PATCH 113/163] List the log levels in the README (dart-lang/logging#97) Other cleanup: - Use `repository` over `homepage. - Use stable SDK and deps. - Drop dependency overrides. - Bump to v1.0 of Dart github action. - Test on the oldest supported SDK. Co-authored-by: John M. Wargo --- .../.github/workflows/test-package.yml | 6 ++--- pkgs/logging/CHANGELOG.md | 4 +++ pkgs/logging/README.md | 25 ++++++++++++++++--- pkgs/logging/pubspec.yaml | 13 +++------- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 0a2a8743..cdc25d95 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.3 + - uses: dart-lang/setup-dart@v1.0 with: sdk: ${{ matrix.sdk }} - id: install @@ -47,10 +47,10 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [dev] + sdk: [2.12.0, dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.3 + - uses: dart-lang/setup-dart@v1.0 with: sdk: ${{ matrix.sdk }} - id: install diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 940d1bf0..e1d9ad37 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.1 + +* List log levels in README. + ## 1.0.0 * Stable null safety release. diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 66ab3166..27b1ec3c 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -16,8 +16,18 @@ Logger.root.onRecord.listen((record) { }); ``` -First, set the root `Level`. All messages at or above the level are sent to the -`onRecord` stream. +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. @@ -47,4 +57,13 @@ evaluated only if the message is actually logged: log.fine(() => [1, 2, 3, 4, 5].map((e) => e * 4).join("-")); ``` -See the `Logger` class for the different logging methods. +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);` diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 4273c4ea..e9e64e74 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,20 +1,15 @@ name: logging -version: 1.0.0 +version: 1.0.1 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: https://github.com/dart-lang/logging +repository: https://github.com/dart-lang/logging environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" dev_dependencies: pedantic: ^1.10.0 - test: ^1.16.0-nullsafety - -dependency_overrides: - # These are required to get a version solve since they depend on this package - coverage: ^0.13.3 - webkit_inspection_protocol: ^0.5.0 + test: ^1.16.0 From a7226fadf655a982ea71a776c7d76ccfaffbeac2 Mon Sep 17 00:00:00 2001 From: Franklin Yow <58489007+franklinyow@users.noreply.github.com> Date: Thu, 1 Apr 2021 17:07:13 -0700 Subject: [PATCH 114/163] Update LICENSE (dart-lang/logging#98) Changes to comply with internal review --- pkgs/logging/LICENSE | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/LICENSE b/pkgs/logging/LICENSE index ee999303..ab3bfa01 100644 --- a/pkgs/logging/LICENSE +++ b/pkgs/logging/LICENSE @@ -1,4 +1,5 @@ -Copyright 2013, the Dart project authors. All rights reserved. +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: @@ -9,7 +10,7 @@ met: 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 Inc. nor the names of its + * 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. From e7ee3bc9b50bbdfdfaa621d61bceca478eff3334 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 22 Jul 2021 14:54:27 -0700 Subject: [PATCH 115/163] Move from pedantic to lints package (dart-lang/logging#102) Fix violation of `prefer_function_declarations_over_variables`. Ignore `constant_identifier_names` in `level.dart` since fixing the violations would be a breaking change. --- pkgs/logging/CHANGELOG.md | 4 +++- pkgs/logging/analysis_options.yaml | 8 ++------ pkgs/logging/lib/src/level.dart | 2 ++ pkgs/logging/pubspec.yaml | 4 ++-- pkgs/logging/test/logging_test.dart | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index e1d9ad37..f648c96d 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.0.2-dev + ## 1.0.1 * List log levels in README. @@ -9,7 +11,7 @@ ## 1.0.0-nullsafety.0 * Migrate to null safety. -* Removed the deprecated `LoggerHandler` typedef. +* Removed the deprecated `LoggerHandler` typedef. ## 0.11.4 diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index fbe6079f..391b2412 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -1,12 +1,8 @@ -include: package:pedantic/analysis_options.yaml +include: package:lints/recommended.yaml analyzer: strong-mode: implicit-casts: false - errors: - unused_element: error - unused_import: error - unused_local_variable: error - dead_code: error + linter: rules: - annotate_overrides diff --git a/pkgs/logging/lib/src/level.dart b/pkgs/logging/lib/src/level.dart index b2f7c88f..36694335 100644 --- a/pkgs/logging/lib/src/level.dart +++ b/pkgs/logging/lib/src/level.dart @@ -2,6 +2,8 @@ // 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. +// ignore_for_file: constant_identifier_names + /// [Level]s to control logging output. Logging can be enabled to include all /// levels above certain [Level]. [Level]s are ordered using an integer /// value [Level.value]. The predefined [Level] constants below are sorted as diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index e9e64e74..090aec85 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.0.1 +version: 1.0.2-dev description: >- Provides APIs for debugging and error logging. This library introduces @@ -11,5 +11,5 @@ environment: sdk: ">=2.12.0 <3.0.0" dev_dependencies: - pedantic: ^1.10.0 + lints: ^1.0.0 test: ^1.16.0 diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index a0c705f3..34f4292f 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -605,7 +605,7 @@ void main() { }); var callCount = 0; - var myClosure = () => '${++callCount}'; + String myClosure() => '${++callCount}'; root.info(myClosure); root.finer(myClosure); // Should not get evaluated. From ed5ce02105b5954ef5c6ebea335867eeffd38a6e Mon Sep 17 00:00:00 2001 From: Michael Thomsen Date: Tue, 14 Sep 2021 17:09:30 +0200 Subject: [PATCH 116/163] Add example, update description (dart-lang/logging#103) --- pkgs/logging/CHANGELOG.md | 5 ++++- pkgs/logging/example/main.dart | 37 ++++++++++++++++++++++++++++++++++ pkgs/logging/pubspec.yaml | 7 +++---- 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 pkgs/logging/example/main.dart diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index f648c96d..cb78ccd3 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,4 +1,7 @@ -## 1.0.2-dev +## 1.0.2 + +* Update description. +* Add example. ## 1.0.1 diff --git a/pkgs/logging/example/main.dart b/pkgs/logging/example/main.dart new file mode 100644 index 00000000..e40d27be --- /dev/null +++ b/pkgs/logging/example/main.dart @@ -0,0 +1,37 @@ +import 'package:logging/logging.dart'; + +final log = Logger('ExampleLogger'); + +/// Example of configuring a logger to print to stdout. +/// +/// This example will print: +/// +/// INFO: 2021-09-13 15:35:10.703401: recursion: n = 4 +/// INFO: 2021-09-13 15:35:10.707974: recursion: n = 3 +/// Fibonacci(4) is: 3 +/// Fibonacci(5) is: 5 +/// SHOUT: 2021-09-13 15:35:10.708087: Unexpected negative n: -42 +/// Fibonacci(-42) is: 1 +void main() { + Logger.root.level = Level.ALL; // defaults to Level.INFO + Logger.root.onRecord.listen((record) { + print('${record.level.name}: ${record.time}: ${record.message}'); + }); + + print('Fibonacci(4) is: ${fibonacci(4)}'); + + Logger.root.level = Level.SEVERE; // skip logs less then severe. + print('Fibonacci(5) is: ${fibonacci(5)}'); + + print('Fibonacci(-42) is: ${fibonacci(-42)}'); +} + +int fibonacci(int n) { + if (n <= 2) { + if (n < 0) log.shout('Unexpected negative n: $n'); + return 1; + } else { + log.info('recursion: n = $n'); + return fibonacci(n - 2) + fibonacci(n - 1); + } +} diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 090aec85..e20a6c95 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,10 +1,9 @@ name: logging -version: 1.0.2-dev +version: 1.0.2 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. + Provides APIs for debugging and error logging, similar to loggers in other + languages, such as the Closure JS Logger and java.util.logging.Logger. repository: https://github.com/dart-lang/logging environment: From a0c2ff4aa423d7f0d7e6da80a30aaecf4b747718 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 15 Feb 2022 16:19:30 -0800 Subject: [PATCH 117/163] Enable the avoid_dynamic_calls lint (dart-lang/logging#112) --- pkgs/logging/CHANGELOG.md | 4 ++++ pkgs/logging/analysis_options.yaml | 2 ++ pkgs/logging/lib/src/logger.dart | 2 +- pkgs/logging/pubspec.yaml | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index cb78ccd3..e3023c79 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.3-dev + +* Enable the `avoid_dynamic_calls` lint. + ## 1.0.2 * Update description. diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index 391b2412..2270a02d 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -1,4 +1,5 @@ include: package:lints/recommended.yaml + analyzer: strong-mode: implicit-casts: false @@ -6,6 +7,7 @@ analyzer: linter: rules: - annotate_overrides + - avoid_dynamic_calls - avoid_function_literals_in_foreach_calls - avoid_init_to_null - avoid_null_checks_in_equality_operators diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index b298b77a..026ec07b 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -174,7 +174,7 @@ class Logger { Object? object; if (isLoggable(logLevel)) { if (message is Function) { - message = message(); + message = (message as Object? Function())(); } String msg; diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index e20a6c95..003c4afd 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.0.2 +version: 1.0.3-dev description: >- Provides APIs for debugging and error logging, similar to loggers in other From d2d1f17eeaeda3f40bd91e1bf1c9e02286d84cc3 Mon Sep 17 00:00:00 2001 From: powerb33 Date: Wed, 16 Feb 2022 11:30:25 -0800 Subject: [PATCH 118/163] Add Logger.attachedLoggers to return the known Logger objects (dart-lang/logging#110) Co-authored-by: Nate Bosch --- pkgs/logging/CHANGELOG.md | 4 +++- pkgs/logging/lib/src/logger.dart | 14 +++++++++++--- pkgs/logging/pubspec.yaml | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index e3023c79..6746eb45 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,5 +1,7 @@ -## 1.0.3-dev +## 1.1.0 +* Add `Logger.attachedLoggers` which exposes all loggers created with the + default constructor. * Enable the `avoid_dynamic_calls` lint. ## 1.0.2 diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index 026ec07b..f702c73b 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -51,8 +51,11 @@ class Logger { /// root [Logger]. StreamController? _controller; - /// Singleton constructor. Calling `new Logger(name)` will return the same - /// actual instance whenever it is called with the same string name. + /// Create or find a Logger by name. + /// + /// Calling `Logger(name)` will return the same instance whenever it is called + /// with the same string name. Loggers created with this constructor are + /// retained indefinitely and available through [attachedLoggers]; factory Logger(String name) => _loggers.putIfAbsent(name, () => Logger._named(name)); @@ -278,6 +281,11 @@ class Logger { /// Top-level root [Logger]. static final Logger root = Logger(''); - /// All [Logger]s in the system. + /// All attached [Logger]s in the system. static final Map _loggers = {}; + + /// All attached [Logger]s in the system. + /// + /// Loggers created with [Logger.detached] are not included. + static Iterable get attachedLoggers => _loggers.values; } diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 003c4afd..0fcd8121 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.0.3-dev +version: 1.1.0 description: >- Provides APIs for debugging and error logging, similar to loggers in other From f10819b0d5f81fe914f77ff8e7c1be35b4d5c5ed Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 25 Jul 2022 13:05:52 -0700 Subject: [PATCH 119/163] Drop invariant_booleans from lints (dart-lang/logging#117) --- pkgs/logging/analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index 2270a02d..b143be9f 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -27,7 +27,6 @@ linter: - empty_statements - hash_and_equals - implementation_imports - - invariant_booleans - iterable_contains_unrelated_type - library_names - library_prefixes From f5c9702593ed68b29bbe00dbe09311b62de53004 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 30 Aug 2022 10:36:04 -0700 Subject: [PATCH 120/163] add file copyrights and misc changes (dart-lang/logging#119) --- pkgs/logging/README.md | 1 + pkgs/logging/lib/src/log_record.dart | 4 ++++ pkgs/logging/lib/src/logger.dart | 6 +++++- pkgs/logging/pubspec.yaml | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 27b1ec3c..5221f062 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -1,5 +1,6 @@ [![Build Status](https://github.com/dart-lang/logging/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/logging/actions?query=workflow%3A"Dart+CI"+branch%3Amaster) [![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 diff --git a/pkgs/logging/lib/src/log_record.dart b/pkgs/logging/lib/src/log_record.dart index c1df3580..8a0ee618 100644 --- a/pkgs/logging/lib/src/log_record.dart +++ b/pkgs/logging/lib/src/log_record.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +// 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. + import 'dart:async'; import 'level.dart'; diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index f702c73b..e15b090d 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file +// 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. + import 'dart:async'; import 'dart:collection'; @@ -55,7 +59,7 @@ class Logger { /// /// Calling `Logger(name)` will return the same instance whenever it is called /// with the same string name. Loggers created with this constructor are - /// retained indefinitely and available through [attachedLoggers]; + /// retained indefinitely and available through [attachedLoggers]. factory Logger(String name) => _loggers.putIfAbsent(name, () => Logger._named(name)); diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 0fcd8121..190df590 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -10,5 +10,5 @@ environment: sdk: ">=2.12.0 <3.0.0" dev_dependencies: - lints: ^1.0.0 + lints: '>=1.0.0 <3.0.0' test: ^1.16.0 From 361204de1b5f460dd1d1a8933a0597c632ef6076 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 5 Oct 2022 11:10:39 -0700 Subject: [PATCH 121/163] update CI config (dart-lang/logging#121) --- pkgs/logging/.github/dependabot.yaml | 8 ++++++++ pkgs/logging/.github/workflows/test-package.yml | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 pkgs/logging/.github/dependabot.yaml diff --git a/pkgs/logging/.github/dependabot.yaml b/pkgs/logging/.github/dependabot.yaml new file mode 100644 index 00000000..21448193 --- /dev/null +++ b/pkgs/logging/.github/dependabot.yaml @@ -0,0 +1,8 @@ +# Dependabot configuration file. +version: 2 + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index cdc25d95..68f255c7 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,8 +22,8 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install @@ -49,8 +49,8 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install From 46490c678c11359f99fb90083d1c0dbaaa33db88 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 6 Dec 2022 11:20:48 -0800 Subject: [PATCH 122/163] Create no-response.yml (dart-lang/logging#124) --- .../logging/.github/workflows/no-response.yml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pkgs/logging/.github/workflows/no-response.yml diff --git a/pkgs/logging/.github/workflows/no-response.yml b/pkgs/logging/.github/workflows/no-response.yml new file mode 100644 index 00000000..fdc1c6aa --- /dev/null +++ b/pkgs/logging/.github/workflows/no-response.yml @@ -0,0 +1,34 @@ +# A workflow to close issues where the author hasn't responded to a request for +# more information; see https://github.com/godofredoc/no-response for docs. + +name: No Response + +# Both `issue_comment` and `scheduled` event types are required. +on: + issue_comment: + types: [created] + schedule: + # Schedule for five minutes after the hour, every hour + - cron: '5 * * * *' + +# All permissions not specified are set to 'none'. +permissions: + issues: write + +jobs: + noResponse: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'dart-lang' }} + steps: + - uses: godofredoc/no-response@0ce2dc0e63e1c7d2b87752ceed091f6d32c9df09 + with: + responseRequiredLabel: "needs-info" + responseRequiredColor: 4774bc + daysUntilClose: 14 + # Comment to post when closing an Issue for lack of response. + closeComment: > + Without additional information we're not able to resolve this + issue, so it will be closed at this time. You're still free to add + more info and respond to any questions above, though. We'll reopen + the case if you do. Thanks for your contribution! + token: ${{ github.token }} From 8c634ac5581591a1328bf37dbc2f0f442175e00d Mon Sep 17 00:00:00 2001 From: Mushaheed Syed Date: Wed, 7 Dec 2022 03:53:52 +0530 Subject: [PATCH 123/163] Add a check that throws if a logger name ends with '.' (dart-lang/logging#123) --- pkgs/logging/CHANGELOG.md | 4 ++++ pkgs/logging/lib/src/logger.dart | 4 ++++ pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 6746eb45..614a9250 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.1-dev + +* Add a check that throws if a logger name ends with '.'. + ## 1.1.0 * Add `Logger.attachedLoggers` which exposes all loggers created with the diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index e15b090d..96ab5561 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -78,6 +78,10 @@ class Logger { if (name.startsWith('.')) { throw ArgumentError("name shouldn't start with a '.'"); } + if (name.endsWith('.')) { + throw ArgumentError("name shouldn't end with a '.'"); + } + // Split hierarchical names (separated with '.'). var dot = name.lastIndexOf('.'); Logger? parent; diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 190df590..da9a1381 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.1.0 +version: 1.1.1-dev description: >- Provides APIs for debugging and error logging, similar to loggers in other diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 34f4292f..20332148 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -75,6 +75,11 @@ void main() { expect(() => Logger('.c'), throwsArgumentError); }); + test('logger name cannot end with a "."', () { + expect(() => Logger('a.'), throwsArgumentError); + expect(() => Logger('a..d'), throwsArgumentError); + }); + test('root level has proper defaults', () { expect(Logger.root, isNotNull); expect(Logger.root.parent, null); From dac77f8143b94186b0521707a75c4364d4055eb4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jan 2023 09:26:41 -0800 Subject: [PATCH 124/163] Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/logging#125) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8...755da8c3cf115ac066823e79a1e1788f8940201b) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 68f255c7..c3560007 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From 58e6fe464db57305be911f6caf253876ea4301a9 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 9 Jan 2023 14:34:57 -0800 Subject: [PATCH 125/163] Move to new analyzer language settings (dart-lang/logging#126) Enable and fix a bunch of lints. Require Dart 2.18 or greater --- .../.github/workflows/test-package.yml | 2 +- pkgs/logging/CHANGELOG.md | 1 + pkgs/logging/analysis_options.yaml | 74 +++++------ pkgs/logging/lib/src/logger.dart | 6 +- pkgs/logging/pubspec.yaml | 4 +- pkgs/logging/test/logging_test.dart | 116 +++++++++--------- 6 files changed, 98 insertions(+), 105 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index c3560007..cc5abcf3 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -47,7 +47,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.12.0, dev] + sdk: [2.18.0, dev] steps: - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 614a9250..afde9c09 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.1.1-dev * Add a check that throws if a logger name ends with '.'. +* Require Dart 2.18 ## 1.1.0 diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index b143be9f..ecc79480 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -1,63 +1,55 @@ +# https://dart.dev/guides/language/analysis-options include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-casts: false + language: + strict-casts: true + strict-raw-types: true linter: rules: - - annotate_overrides + - always_declare_return_types + - avoid_bool_literals_in_conditional_expressions + - avoid_catching_errors + - avoid_classes_with_only_static_members - avoid_dynamic_calls - - avoid_function_literals_in_foreach_calls - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_relative_lib_imports + - avoid_private_typedef_functions + - avoid_redundant_argument_values - avoid_returning_null + - avoid_returning_null_for_future + - avoid_returning_this - avoid_unused_constructor_parameters - - await_only_futures - - camel_case_types + - avoid_void_async - cancel_subscriptions - comment_references - # See https://github.com/dart-lang/logging/issues/43 - #- constant_identifier_names - - control_flow_in_finally - directives_ordering - - empty_catches - - empty_constructor_bodies - - empty_statements - - hash_and_equals - - implementation_imports - - iterable_contains_unrelated_type - - library_names - - library_prefixes - - list_remove_unrelated_type + - join_return_with_assignment + - lines_longer_than_80_chars + - literal_only_boolean_expressions + - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - - non_constant_identifier_names + - no_runtimeType_toString - omit_local_variable_types - only_throw_errors - - overridden_fields - package_api_docs - - package_names - - package_prefixed_library_names - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment + - prefer_asserts_in_initializer_lists - prefer_const_constructors - - prefer_final_fields - - prefer_generic_function_type_aliases - - prefer_initializing_formals - - prefer_interpolation_to_compose_strings + - prefer_const_declarations + - prefer_expression_function_bodies + - prefer_final_locals + - prefer_relative_imports - prefer_single_quotes - - prefer_typing_uninitialized_variables - - slash_for_doc_comments + - sort_pub_dependencies - test_types_in_equals - throw_in_finally - - type_init_formals - - unnecessary_brace_in_string_interps - - unnecessary_const - - unnecessary_getters_setters + - type_annotate_public_apis + - unawaited_futures + - unnecessary_await_in_return - unnecessary_lambdas - - unnecessary_new - - unnecessary_null_aware_assignments + - unnecessary_parenthesis + - unnecessary_raw_strings - unnecessary_statements - - unnecessary_this + - use_if_null_to_convert_nulls_to_bools + - use_raw_strings + - use_string_buffers + - use_super_parameters diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index 96ab5561..f90fd063 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -83,7 +83,7 @@ class Logger { } // Split hierarchical names (separated with '.'). - var dot = name.lastIndexOf('.'); + final dot = name.lastIndexOf('.'); Logger? parent; String thisName; if (dot == -1) { @@ -161,7 +161,7 @@ class Logger { } /// Whether a message for [value]'s level is loggable in this logger. - bool isLoggable(Level value) => (value >= level); + bool isLoggable(Level value) => value >= level; /// Adds a log record for a [message] at a particular [logLevel] if /// `isLoggable(logLevel)` is true. @@ -202,7 +202,7 @@ class Logger { } zone ??= Zone.current; - var record = + final record = LogRecord(logLevel, msg, fullName, error, stackTrace, zone, object); if (parent == null) { diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index da9a1381..d0f68945 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -7,8 +7,8 @@ description: >- repository: https://github.com/dart-lang/logging environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.18.0 <3.0.0" dev_dependencies: - lints: '>=1.0.0 <3.0.0' + lints: ^2.0.0 test: ^1.16.0 diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 20332148..4a7d40a5 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -13,26 +13,26 @@ void main() { final hierarchicalLoggingEnabledDefault = hierarchicalLoggingEnabled; test('level comparison is a valid comparator', () { - var level1 = const Level('NOT_REAL1', 253); + const level1 = Level('NOT_REAL1', 253); expect(level1 == level1, isTrue); expect(level1 <= level1, isTrue); expect(level1 >= level1, isTrue); expect(level1 < level1, isFalse); expect(level1 > level1, isFalse); - var level2 = const Level('NOT_REAL2', 455); + const level2 = Level('NOT_REAL2', 455); expect(level1 <= level2, isTrue); expect(level1 < level2, isTrue); expect(level2 >= level1, isTrue); expect(level2 > level1, isTrue); - var level3 = const Level('NOT_REAL3', 253); + const level3 = Level('NOT_REAL3', 253); expect(level1, isNot(same(level3))); // different instances expect(level1, equals(level3)); // same value. }); test('default levels are in order', () { - final levels = Level.LEVELS; + const levels = Level.LEVELS; for (var i = 0; i < levels.length; i++) { for (var j = i + 1; j < levels.length; j++) { @@ -55,7 +55,7 @@ void main() { Level.SEVERE, ]; - final sorted = Level.LEVELS; + const sorted = Level.LEVELS; expect(unsorted, isNot(orderedEquals(sorted))); @@ -64,7 +64,7 @@ void main() { }); test('levels are hashable', () { - var map = {}; + final map = {}; map[Level.INFO] = 'info'; map[Level.SHOUT] = 'shout'; expect(map[Level.INFO], same('info')); @@ -87,7 +87,7 @@ void main() { }); test('logger naming is hierarchical', () { - var c = Logger('a.b.c'); + final c = Logger('a.b.c'); expect(c.name, equals('c')); expect(c.parent!.name, equals('b')); expect(c.parent!.parent!.name, equals('a')); @@ -96,7 +96,7 @@ void main() { }); test('logger full name', () { - var c = Logger('a.b.c'); + final c = Logger('a.b.c'); expect(c.fullName, equals('a.b.c')); expect(c.parent!.fullName, equals('a.b')); expect(c.parent!.parent!.fullName, equals('a')); @@ -105,9 +105,9 @@ void main() { }); test('logger parent-child links are correct', () { - var a = Logger('a'); - var b = Logger('a.b'); - var c = Logger('a.c'); + final a = Logger('a'); + final b = Logger('a.b'); + final c = Logger('a.c'); expect(a, same(b.parent)); expect(a, same(c.parent)); expect(a.children['b'], same(b)); @@ -115,10 +115,10 @@ void main() { }); test('loggers are singletons', () { - var a1 = Logger('a'); - var a2 = Logger('a'); - var b = Logger('a.b'); - var root = Logger.root; + final a1 = Logger('a'); + final a2 = Logger('a'); + final b = Logger('a.b'); + final root = Logger.root; expect(a1, same(a2)); expect(a1, same(b.parent)); expect(root, same(a1.parent)); @@ -126,8 +126,8 @@ void main() { }); test('cannot directly manipulate Logger.children', () { - var loggerAB = Logger('a.b'); - var loggerA = loggerAB.parent!; + final loggerAB = Logger('a.b'); + final loggerA = loggerAB.parent!; expect(loggerA.children['b'], same(loggerAB), reason: 'can read Children'); @@ -139,9 +139,9 @@ void main() { test('stackTrace gets throw to LogRecord', () { Logger.root.level = Level.INFO; - var records = []; + final records = []; - var sub = Logger.root.onRecord.listen(records.add); + final sub = Logger.root.onRecord.listen(records.add); try { throw UnsupportedError('test exception'); @@ -156,17 +156,17 @@ void main() { expect(records, hasLength(3)); - var severe = records[0]; + final severe = records[0]; expect(severe.message, 'severe'); expect(severe.error is UnsupportedError, isTrue); expect(severe.stackTrace is StackTrace, isTrue); - var warning = records[1]; + final warning = records[1]; expect(warning.message, 'warning'); expect(warning.error is UnsupportedError, isTrue); expect(warning.stackTrace is StackTrace, isTrue); - var shout = records[2]; + final shout = records[2]; expect(shout.message, 'shout'); expect(shout.error, isNull); expect(shout.stackTrace, isNull); @@ -174,10 +174,10 @@ void main() { group('zone gets recorded to LogRecord', () { test('root zone', () { - var root = Logger.root; + final root = Logger.root; - var recordingZone = Zone.current; - var records = []; + final recordingZone = Zone.current; + final records = []; root.onRecord.listen(records.add); root.info('hello'); @@ -186,10 +186,10 @@ void main() { }); test('child zone', () { - var root = Logger.root; + final root = Logger.root; late Zone recordingZone; - var records = []; + final records = []; root.onRecord.listen(records.add); runZoned(() { @@ -202,10 +202,10 @@ void main() { }); test('custom zone', () { - var root = Logger.root; + final root = Logger.root; late Zone recordingZone; - var records = []; + final records = []; root.onRecord.listen(records.add); runZoned(() { @@ -226,9 +226,9 @@ void main() { }); test('create new instances of Logger', () { - var a1 = Logger.detached('a'); - var a2 = Logger.detached('a'); - var a = Logger('a'); + final a1 = Logger.detached('a'); + final a2 = Logger.detached('a'); + final a = Logger('a'); expect(a1, isNot(a2)); expect(a1, isNot(a)); @@ -236,12 +236,12 @@ void main() { }); test('parent is null', () { - var a = Logger.detached('a'); + final a = Logger.detached('a'); expect(a.parent, null); }); test('children is empty', () { - var a = Logger.detached('a'); + final a = Logger.detached('a'); expect(a.children, {}); }); @@ -292,12 +292,12 @@ void main() { }); group('mutating levels', () { - var root = Logger.root; - var a = Logger('a'); - var b = Logger('a.b'); - var c = Logger('a.b.c'); - var d = Logger('a.b.c.d'); - var e = Logger('a.b.c.d.e'); + final root = Logger.root; + final a = Logger('a'); + final b = Logger('a.b'); + final c = Logger('a.b.c'); + final d = Logger('a.b.c.d'); + final e = Logger('a.b.c.d.e'); setUp(() { hierarchicalLoggingEnabled = true; @@ -411,7 +411,7 @@ void main() { test('logging methods store appropriate level', () { root.level = Level.ALL; - var rootMessages = []; + final rootMessages = []; root.onRecord.listen((record) { rootMessages.add('${record.level}: ${record.message}'); }); @@ -441,7 +441,7 @@ void main() { test('logging methods store exception', () { root.level = Level.ALL; - var rootMessages = []; + final rootMessages = []; root.onRecord.listen((r) { rootMessages.add('${r.level}: ${r.message} ${r.error}'); }); @@ -487,9 +487,9 @@ void main() { test('message logging - no hierarchy', () { root.level = Level.WARNING; - var rootMessages = []; - var aMessages = []; - var cMessages = []; + final rootMessages = []; + final aMessages = []; + final cMessages = []; c.onRecord.listen((record) { cMessages.add('${record.level}: ${record.message}'); }); @@ -538,9 +538,9 @@ void main() { b.level = Level.WARNING; - var rootMessages = []; - var aMessages = []; - var cMessages = []; + final rootMessages = []; + final aMessages = []; + final cMessages = []; c.onRecord.listen((record) { cMessages.add('${record.level}: ${record.message}'); }); @@ -604,7 +604,7 @@ void main() { test('message logging - lazy functions', () { root.level = Level.INFO; - var messages = []; + final messages = []; root.onRecord.listen((record) { messages.add('${record.level}: ${record.message}'); }); @@ -626,9 +626,9 @@ void main() { test('message logging - calls toString', () { root.level = Level.INFO; - var messages = []; - var objects = []; - var object = Object(); + final messages = []; + final objects = []; + final object = Object(); root.onRecord.listen((record) { messages.add('${record.level}: ${record.message}'); objects.add(record.object); @@ -661,14 +661,14 @@ void main() { }); group('recordStackTraceAtLevel', () { - var root = Logger.root; + final root = Logger.root; tearDown(() { recordStackTraceAtLevel = Level.OFF; root.clearListeners(); }); test('no stack trace by default', () { - var records = []; + final records = []; root.onRecord.listen(records.add); root.severe('hello'); root.warning('hello'); @@ -680,7 +680,7 @@ void main() { }); test('trace recorded only on requested levels', () { - var records = []; + final records = []; recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); root.severe('hello'); @@ -693,8 +693,8 @@ void main() { }); test('provided trace is used if given', () { - var trace = StackTrace.current; - var records = []; + final trace = StackTrace.current; + final records = []; recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); root.severe('hello'); @@ -705,7 +705,7 @@ void main() { }); test('error also generated when generating a trace', () { - var records = []; + final records = []; recordStackTraceAtLevel = Level.WARNING; root.onRecord.listen(records.add); root.severe('hello'); From 14656116b435ae50056f49c34c7e7e3f0963d6e5 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 26 Jan 2023 10:05:38 -0800 Subject: [PATCH 126/163] add a publish script; prep to publish 1.1.1 (dart-lang/logging#128) * blast_repo fixes auto-publish * rev to 1.1.1 --- pkgs/logging/.github/workflows/publish.yaml | 14 ++++++++++++++ pkgs/logging/CHANGELOG.md | 2 +- pkgs/logging/README.md | 5 +++++ pkgs/logging/pubspec.yaml | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 pkgs/logging/.github/workflows/publish.yaml diff --git a/pkgs/logging/.github/workflows/publish.yaml b/pkgs/logging/.github/workflows/publish.yaml new file mode 100644 index 00000000..fcb7ccb8 --- /dev/null +++ b/pkgs/logging/.github/workflows/publish.yaml @@ -0,0 +1,14 @@ +# A CI configuration to auto-publish pub packages. + +name: Publish + +on: + pull_request: + branches: [ master ] + push: + tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ] + +jobs: + publish: + if: ${{ github.repository_owner == 'dart-lang' }} + uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index afde9c09..9117b879 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.1.1-dev +## 1.1.1 * Add a check that throws if a logger name ends with '.'. * Require Dart 2.18 diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 5221f062..51b1ae15 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -68,3 +68,8 @@ Available logging methods are: + `log.fine(logged_content);` + `log.finer(logged_content);` + `log.finest(logged_content);` + +## Publishing automation + +For information about our publishing automation and release process, see +https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index d0f68945..8921a122 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.1.1-dev +version: 1.1.1 description: >- Provides APIs for debugging and error logging, similar to loggers in other From 5f86536375cd46bc99ae86d58714d6a20e0e1ee8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:30:21 -0800 Subject: [PATCH 127/163] Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/logging#129) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/755da8c3cf115ac066823e79a1e1788f8940201b...ac593985615ec2ede58e132d2e21d2b1cbd6127c) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index cc5abcf3..e9d2eb96 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From 9d5989a62b9e94ec83a34d156142bdf7e4c19dfd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:34:20 -0800 Subject: [PATCH 128/163] Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/logging#130) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.3 to 1.4. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/6a218f2413a3e78e9087f638a238f6b40893203d...a57a6c04cf7d4840e88432aad6281d1e125f0d46) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index e9d2eb96..5a03db3b 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install From ddaeb5629e13d4c58468d986c480b1242ca6a5f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 15:40:30 -0700 Subject: [PATCH 129/163] Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/logging#134) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/a57a6c04cf7d4840e88432aad6281d1e125f0d46...d6a63dab3335f427404425de0fbfed4686d93c4f) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 5a03db3b..2874adcb 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install @@ -50,7 +50,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install From 6d92fd8ffeb6be92799fa02190a2f6006abee1d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 15:57:17 -0700 Subject: [PATCH 130/163] Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/logging#133) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/ac593985615ec2ede58e132d2e21d2b1cbd6127c...8f4b7f84864484a7bf31766abe9204da3cbe65b3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 2874adcb..b70103cd 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 682f769c99bb2546807aac9acdaeb95800344c61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 12:27:58 -0700 Subject: [PATCH 131/163] Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/logging#136) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8f4b7f84864484a7bf31766abe9204da3cbe65b3...8e5e7e5ab8b370d6c329ec480221332ada57f0ab) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index b70103cd..2d36a3b1 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 0e7b4df1ce52bea57bd51509ddc227c0f9de708b Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 10 May 2023 11:37:07 -0700 Subject: [PATCH 132/163] blast_repo fixes (dart-lang/logging#137) * blast_repo fixes no-response * update analysis and test matrix --- .../logging/.github/workflows/no-response.yml | 12 +++++------ .../.github/workflows/test-package.yml | 11 ++++------ pkgs/logging/CHANGELOG.md | 4 ++++ pkgs/logging/analysis_options.yaml | 20 +------------------ pkgs/logging/pubspec.yaml | 7 +++---- pkgs/logging/test/logging_test.dart | 2 -- 6 files changed, 18 insertions(+), 38 deletions(-) diff --git a/pkgs/logging/.github/workflows/no-response.yml b/pkgs/logging/.github/workflows/no-response.yml index fdc1c6aa..ac3e456e 100644 --- a/pkgs/logging/.github/workflows/no-response.yml +++ b/pkgs/logging/.github/workflows/no-response.yml @@ -8,8 +8,8 @@ on: issue_comment: types: [created] schedule: - # Schedule for five minutes after the hour, every hour - - cron: '5 * * * *' + # Every day at 8am + - cron: '0 8 * * *' # All permissions not specified are set to 'none'. permissions: @@ -27,8 +27,8 @@ jobs: daysUntilClose: 14 # Comment to post when closing an Issue for lack of response. closeComment: > - Without additional information we're not able to resolve this - issue, so it will be closed at this time. You're still free to add - more info and respond to any questions above, though. We'll reopen - the case if you do. Thanks for your contribution! + Without additional information we're not able to resolve this issue, + so it will be closed at this time. You're still free to add more + info and respond to any questions above, though. We'll reopen the + issue if you do. Thanks for your contribution! token: ${{ github.token }} diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 2d36a3b1..a9d2c986 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -13,14 +13,13 @@ env: PUB_ENVIRONMENT: bot.github jobs: - # Check code formatting and static analysis on a single OS (linux) - # against Dart dev. + # Check code formatting and static analysis. analyze: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - sdk: [dev] + sdk: [stable] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f @@ -36,9 +35,7 @@ jobs: run: dart analyze --fatal-infos if: always() && steps.install.outcome == 'success' - # Run tests on a matrix consisting of two dimensions: - # 1. OS: ubuntu-latest, (macos-latest, windows-latest) - # 2. release channel: dev + # Run tests on a matrix of platforms and sdk versions. test: needs: analyze runs-on: ${{ matrix.os }} @@ -47,7 +44,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.18.0, dev] + sdk: [2.19.0, stable, beta] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 9117b879..489b0eb9 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.2-wip + +* Require Dart 2.19. + ## 1.1.1 * Add a check that throws if a logger name ends with '.'. diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index ecc79480..a0097f63 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -1,54 +1,36 @@ # https://dart.dev/guides/language/analysis-options -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: - strict-casts: true strict-raw-types: true linter: rules: - - always_declare_return_types - avoid_bool_literals_in_conditional_expressions - - avoid_catching_errors - avoid_classes_with_only_static_members - - avoid_dynamic_calls - avoid_private_typedef_functions - avoid_redundant_argument_values - - avoid_returning_null - avoid_returning_null_for_future - avoid_returning_this - avoid_unused_constructor_parameters - avoid_void_async - cancel_subscriptions - comment_references - - directives_ordering - join_return_with_assignment - - lines_longer_than_80_chars - literal_only_boolean_expressions - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - - omit_local_variable_types - - only_throw_errors - package_api_docs - - prefer_asserts_in_initializer_lists - prefer_const_constructors - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals - prefer_relative_imports - - prefer_single_quotes - - sort_pub_dependencies - test_types_in_equals - - throw_in_finally - - type_annotate_public_apis - - unawaited_futures - unnecessary_await_in_return - - unnecessary_lambdas - - unnecessary_parenthesis - unnecessary_raw_strings - - unnecessary_statements - use_if_null_to_convert_nulls_to_bools - use_raw_strings - use_string_buffers diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 8921a122..089a1140 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,14 +1,13 @@ name: logging -version: 1.1.1 - +version: 1.1.2-wip description: >- Provides APIs for debugging and error logging, similar to loggers in other languages, such as the Closure JS Logger and java.util.logging.Logger. repository: https://github.com/dart-lang/logging environment: - sdk: ">=2.18.0 <3.0.0" + sdk: '>=2.19.0 <4.0.0' dev_dependencies: - lints: ^2.0.0 + dart_flutter_team_lints: ^1.0.0 test: ^1.16.0 diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 4a7d40a5..f41723e3 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -2,8 +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'; import 'package:logging/logging.dart'; From 0f5e913948c942f2629311f5b4f641d3d69fbe60 Mon Sep 17 00:00:00 2001 From: Desislava Stefanova <95419820+desistefanova@users.noreply.github.com> Date: Thu, 18 May 2023 18:38:14 +0300 Subject: [PATCH 133/163] Logger `onLevelChanged` notification (dart-lang/logging#138) Notify when the log level is changed. Logger `onLevelChanged` broadcasts a stream of level values. Fixes dart-lang/logging#139 --- pkgs/logging/CHANGELOG.md | 3 ++- pkgs/logging/README.md | 8 ++++++++ pkgs/logging/lib/src/logger.dart | 22 ++++++++++++++++++++++ pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 27 +++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 489b0eb9..46f1d32d 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,5 +1,6 @@ -## 1.1.2-wip +## 1.2.0-wip +* Add notification when the log level is changed. Logger `onLevelChanged` broadcasts a stream of level values. * Require Dart 2.19. ## 1.1.1 diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 51b1ae15..5b96de1d 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -33,6 +33,14 @@ First, set the root `Level`. All messages at or above the current level are sent 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 notitfications 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 diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index f90fd063..bf27f505 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -55,6 +55,9 @@ class Logger { /// root [Logger]. StreamController? _controller; + /// Controller used to notify when the log level of this logger is changed. + StreamController? _levelChangedController; + /// Create or find a Logger by name. /// /// Calling `Logger(name)` will return the same instance whenever it is called @@ -139,7 +142,26 @@ class Logger { throw UnsupportedError( 'Cannot set the level to `null` on a logger with no parent.'); } + final isLevelChanged = _level != value; _level = value; + if (isLevelChanged) { + _levelChangedController?.add(value); + } + } + + /// Returns a stream of level values set to this [Logger]. + /// + /// You can listen for set levels using the standard stream APIs, + /// for instance: + /// + /// ```dart + /// logger.onLevelChanged.listen((level) { ... }); + /// ``` + /// A state error will be thrown if the level is changed + /// inside the callback. + Stream get onLevelChanged { + _levelChangedController ??= StreamController.broadcast(sync: true); + return _levelChangedController!.stream; } /// Returns a stream of messages added to this [Logger]. diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 089a1140..d75e5b1d 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.1.2-wip +version: 1.2.0-wip description: >- Provides APIs for debugging and error logging, similar to loggers in other languages, such as the Closure JS Logger and java.util.logging.Logger. diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index f41723e3..0c9bd666 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -714,5 +714,32 @@ void main() { expect(records[1].error, isNotNull); expect(records[2].error, isNull); }); + + test('listen for level changed', () { + final levels = []; + root.level = Level.ALL; + root.onLevelChanged.listen(levels.add); + root.level = Level.SEVERE; + root.level = Level.WARNING; + expect(levels, hasLength(2)); + }); + + test('onLevelChanged is not emited if set the level to the same value', () { + final levels = []; + root.level = Level.ALL; + root.onLevelChanged.listen(levels.add); + root.level = Level.ALL; + expect(levels, hasLength(0)); + }); + + test('setting level in a loop throws state error', () { + root.level = Level.ALL; + root.onLevelChanged.listen((event) { + // Cannot fire new event. Controller is already firing an event + expect(() => root.level = Level.SEVERE, throwsStateError); + }); + root.level = Level.WARNING; + expect(root.level, Level.SEVERE); + }); }); } From 627428e260057646121dbcf6716fbb007f7a7206 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 22 May 2023 09:21:03 -0700 Subject: [PATCH 134/163] blast_repo fixes (dart-lang/logging#141) dependabot --- pkgs/logging/.github/dependabot.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/.github/dependabot.yaml b/pkgs/logging/.github/dependabot.yaml index 21448193..439e796b 100644 --- a/pkgs/logging/.github/dependabot.yaml +++ b/pkgs/logging/.github/dependabot.yaml @@ -2,7 +2,9 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "monthly" + interval: monthly + labels: + - autosubmit From 9b172722ba4b0a4d683c1e6da3d095efeedc499f Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 22 May 2023 10:14:28 -0700 Subject: [PATCH 135/163] blast_repo fixes (dart-lang/logging#142) no-response --- .../logging/.github/workflows/no-response.yml | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/pkgs/logging/.github/workflows/no-response.yml b/pkgs/logging/.github/workflows/no-response.yml index ac3e456e..dd7bbbc0 100644 --- a/pkgs/logging/.github/workflows/no-response.yml +++ b/pkgs/logging/.github/workflows/no-response.yml @@ -1,12 +1,10 @@ # A workflow to close issues where the author hasn't responded to a request for -# more information; see https://github.com/godofredoc/no-response for docs. +# more information; see https://github.com/actions/stale. name: No Response -# Both `issue_comment` and `scheduled` event types are required. +# Run as a daily cron. on: - issue_comment: - types: [created] schedule: # Every day at 8am - cron: '0 8 * * *' @@ -14,21 +12,24 @@ on: # All permissions not specified are set to 'none'. permissions: issues: write + pull-requests: write jobs: - noResponse: + no-response: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'dart-lang' }} steps: - - uses: godofredoc/no-response@0ce2dc0e63e1c7d2b87752ceed091f6d32c9df09 + - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 with: - responseRequiredLabel: "needs-info" - responseRequiredColor: 4774bc - daysUntilClose: 14 - # Comment to post when closing an Issue for lack of response. - closeComment: > - Without additional information we're not able to resolve this issue, - so it will be closed at this time. You're still free to add more - info and respond to any questions above, though. We'll reopen the - issue if you do. Thanks for your contribution! - token: ${{ github.token }} + days-before-stale: -1 + days-before-close: 14 + stale-issue-label: "needs-info" + close-issue-message: > + Without additional information we're not able to resolve this issue. + Feel free to add more info or respond to any questions above and we + can reopen the case. Thanks for your contribution! + stale-pr-label: "needs-info" + close-pr-message: > + Without additional information we're not able to resolve this PR. + Feel free to add more info or respond to any questions above. + Thanks for your contribution! From 0bb76e506369d3e924b15dc20804cac469d97c82 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 23 May 2023 15:01:13 -0700 Subject: [PATCH 136/163] prep for release (dart-lang/logging#140) --- pkgs/logging/CHANGELOG.md | 2 +- pkgs/logging/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 46f1d32d..872f9f02 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.2.0-wip +## 1.2.0 * Add notification when the log level is changed. Logger `onLevelChanged` broadcasts a stream of level values. * Require Dart 2.19. diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index d75e5b1d..3a5eebbb 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.2.0-wip +version: 1.2.0 description: >- Provides APIs for debugging and error logging, similar to loggers in other languages, such as the Closure JS Logger and java.util.logging.Logger. From 4d6045e4cfda0a6c6b29ed30bc52ab820b8fc116 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jul 2023 06:50:13 +0000 Subject: [PATCH 137/163] Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/logging#144) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
Release notes

Sourced from actions/checkout's releases.

v3.5.3

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v3.5.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

v2.3.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.2&new-version=3.5.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index a9d2c986..961eb018 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -21,7 +21,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest] sdk: [2.19.0, stable, beta] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From edaceebd2f00271b9ec292ab6361870c97aef80a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 06:49:03 +0000 Subject: [PATCH 138/163] Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/logging#147) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
Release notes

Sourced from actions/checkout's releases.

v3.6.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.3&new-version=3.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 961eb018..31a6da84 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -21,7 +21,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest] sdk: [2.19.0, stable, beta] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From da0bdaef37baeb7609cf6438f3d05fdb20836bed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 06:34:09 +0000 Subject: [PATCH 139/163] Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/logging#148) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.0.
Release notes

Sourced from actions/checkout's releases.

v4.1.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.0.0...v4.1.0

v4.0.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v4.0.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.6.0&new-version=4.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 31a6da84..e66db86d 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -21,7 +21,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest] sdk: [2.19.0, stable, beta] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From cc91899fad67938c91ca7ffab97d28b0e796f65e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 06:37:18 +0000 Subject: [PATCH 140/163] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/logging#149) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.0 to 1.5.1.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (dart-lang/logging#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (dart-lang/logging#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.0&new-version=1.5.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index e66db86d..0bb63f2b 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: sdk: [stable] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install @@ -47,7 +47,7 @@ jobs: sdk: [2.19.0, stable, beta] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install From cccfda50efcf3f49f104307dd08ff6b77eb60b4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 06:16:57 +0000 Subject: [PATCH 141/163] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/logging#151) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.1 to 1.6.0.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (dart-lang/logging#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (dart-lang/logging#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.1&new-version=1.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 0bb63f2b..37d30956 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: sdk: [stable] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install @@ -47,7 +47,7 @@ jobs: sdk: [2.19.0, stable, beta] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install From f2c4229b54be7dde68c374f7d759145ed854a9ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:28:48 +0000 Subject: [PATCH 142/163] Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/logging#150) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
Release notes

Sourced from actions/checkout's releases.

v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.0...v4.1.1

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.0&new-version=4.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 37d30956..1f9161bc 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -21,7 +21,7 @@ jobs: matrix: sdk: [stable] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest] sdk: [2.19.0, stable, beta] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} From 098675ae3bbe858f778df78f291afa775207f52a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 06:54:05 +0000 Subject: [PATCH 143/163] Bump actions/stale from 8.0.0 to 9.0.0 (dart-lang/logging#152) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/stale](https://github.com/actions/stale) from 8.0.0 to 9.0.0.
Release notes

Sourced from actions/stale's releases.

v9.0.0

Breaking Changes

  1. Action is now stateful: If the action ends because of operations-per-run then the next run will start from the first unprocessed issue skipping the issues processed during the previous run(s). The state is reset when all the issues are processed. This should be considered for scheduling workflow runs.
  2. Version 9 of this action updated the runtime to Node.js 20. All scripts are now run with Node.js 20 instead of Node.js 16 and are affected by any breaking changes between Node.js 16 and 20.

What Else Changed

  1. Performance optimization that removes unnecessary API calls by @​dsame dart-lang/logging#1033 fixes dart-lang/logging#792
  2. Logs displaying current github API rate limit by @​dsame dart-lang/logging#1032 addresses dart-lang/logging#1029

For more information, please read the action documentation and its section about statefulness

New Contributors

Full Changelog: https://github.com/actions/stale/compare/v8...v9.0.0

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/stale&package-manager=github_actions&previous-version=8.0.0&new-version=9.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/no-response.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/.github/workflows/no-response.yml b/pkgs/logging/.github/workflows/no-response.yml index dd7bbbc0..1a6f2ecd 100644 --- a/pkgs/logging/.github/workflows/no-response.yml +++ b/pkgs/logging/.github/workflows/no-response.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'dart-lang' }} steps: - - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 + - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e with: days-before-stale: -1 days-before-close: 14 From bef87f3a0259662f6f83b91fa3c4850b29c2de65 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 18 Jan 2024 09:04:36 -0800 Subject: [PATCH 144/163] blast_repo fixes (dart-lang/logging#154) auto-publish, github-actions, no-response --- pkgs/logging/.github/workflows/no-response.yml | 2 ++ pkgs/logging/.github/workflows/publish.yaml | 5 ++++- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/.github/workflows/no-response.yml b/pkgs/logging/.github/workflows/no-response.yml index 1a6f2ecd..ab1ac498 100644 --- a/pkgs/logging/.github/workflows/no-response.yml +++ b/pkgs/logging/.github/workflows/no-response.yml @@ -21,7 +21,9 @@ jobs: steps: - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e with: + # Don't automatically mark inactive issues+PRs as stale. days-before-stale: -1 + # Close needs-info issues and PRs after 14 days of inactivity. days-before-close: 14 stale-issue-label: "needs-info" close-issue-message: > diff --git a/pkgs/logging/.github/workflows/publish.yaml b/pkgs/logging/.github/workflows/publish.yaml index fcb7ccb8..27157a04 100644 --- a/pkgs/logging/.github/workflows/publish.yaml +++ b/pkgs/logging/.github/workflows/publish.yaml @@ -6,9 +6,12 @@ on: pull_request: branches: [ master ] push: - tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ] + tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] jobs: publish: if: ${{ github.repository_owner == 'dart-lang' }} uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main + permissions: + id-token: write # Required for authentication using OIDC + pull-requests: write # Required for writing the pull request note diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 1f9161bc..1535d97c 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: sdk: [stable] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: ${{ matrix.sdk }} - id: install @@ -47,7 +47,7 @@ jobs: sdk: [2.19.0, stable, beta] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: ${{ matrix.sdk }} - id: install From b539ee9aefadbf9c4699f01f9f4e0f98e4313b2f Mon Sep 17 00:00:00 2001 From: Craig Labenz Date: Thu, 18 Jan 2024 09:20:53 -0800 Subject: [PATCH 145/163] Hierarchical logging documentation (dart-lang/logging#146) --- pkgs/logging/README.md | 63 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 5b96de1d..70f16604 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -77,6 +77,69 @@ Available logging methods are: + `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 (√√) +``` + ## Publishing automation For information about our publishing automation and release process, see From 2de688a0b0d1b6024a4f0cbfc0f0e37fc2334d1e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 18 Jan 2024 09:56:48 -0800 Subject: [PATCH 146/163] update min SDK and deps (dart-lang/logging#155) --- .../.github/workflows/test-package.yml | 4 ++-- pkgs/logging/CHANGELOG.md | 4 ++++ pkgs/logging/analysis_options.yaml | 6 ----- pkgs/logging/pubspec.yaml | 6 ++--- pkgs/logging/test/logging_test.dart | 24 +++++++++---------- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 1535d97c..1e34fae8 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - sdk: [stable] + sdk: [dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b @@ -44,7 +44,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.19.0, stable, beta] + sdk: [3.2, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 872f9f02..41843d89 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.1-wip + +* Require Dart 3.2 + ## 1.2.0 * Add notification when the log level is changed. Logger `onLevelChanged` broadcasts a stream of level values. diff --git a/pkgs/logging/analysis_options.yaml b/pkgs/logging/analysis_options.yaml index a0097f63..7c004e0f 100644 --- a/pkgs/logging/analysis_options.yaml +++ b/pkgs/logging/analysis_options.yaml @@ -11,27 +11,21 @@ linter: - avoid_classes_with_only_static_members - avoid_private_typedef_functions - avoid_redundant_argument_values - - avoid_returning_null_for_future - avoid_returning_this - avoid_unused_constructor_parameters - avoid_void_async - cancel_subscriptions - - comment_references - join_return_with_assignment - literal_only_boolean_expressions - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - package_api_docs - - prefer_const_constructors - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals - - prefer_relative_imports - - test_types_in_equals - unnecessary_await_in_return - unnecessary_raw_strings - use_if_null_to_convert_nulls_to_bools - use_raw_strings - use_string_buffers - - use_super_parameters diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 3a5eebbb..6d05e986 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,13 +1,13 @@ name: logging -version: 1.2.0 +version: 1.2.1-wip description: >- Provides APIs for debugging and error logging, similar to loggers in other languages, such as the Closure JS Logger and java.util.logging.Logger. repository: https://github.com/dart-lang/logging environment: - sdk: '>=2.19.0 <4.0.0' + sdk: ^3.2.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 test: ^1.16.0 diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 0c9bd666..7edabb08 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -240,7 +240,7 @@ void main() { test('children is empty', () { final a = Logger.detached('a'); - expect(a.children, {}); + expect(a.children, {}); }); test('have levels independent of the root level', () { @@ -409,7 +409,7 @@ void main() { test('logging methods store appropriate level', () { root.level = Level.ALL; - final rootMessages = []; + final rootMessages = []; root.onRecord.listen((record) { rootMessages.add('${record.level}: ${record.message}'); }); @@ -439,7 +439,7 @@ void main() { test('logging methods store exception', () { root.level = Level.ALL; - final rootMessages = []; + final rootMessages = []; root.onRecord.listen((r) { rootMessages.add('${r.level}: ${r.message} ${r.error}'); }); @@ -485,9 +485,9 @@ void main() { test('message logging - no hierarchy', () { root.level = Level.WARNING; - final rootMessages = []; - final aMessages = []; - final cMessages = []; + final rootMessages = []; + final aMessages = []; + final cMessages = []; c.onRecord.listen((record) { cMessages.add('${record.level}: ${record.message}'); }); @@ -536,9 +536,9 @@ void main() { b.level = Level.WARNING; - final rootMessages = []; - final aMessages = []; - final cMessages = []; + final rootMessages = []; + final aMessages = []; + final cMessages = []; c.onRecord.listen((record) { cMessages.add('${record.level}: ${record.message}'); }); @@ -602,7 +602,7 @@ void main() { test('message logging - lazy functions', () { root.level = Level.INFO; - final messages = []; + final messages = []; root.onRecord.listen((record) { messages.add('${record.level}: ${record.message}'); }); @@ -624,8 +624,8 @@ void main() { test('message logging - calls toString', () { root.level = Level.INFO; - final messages = []; - final objects = []; + final messages = []; + final objects = []; final object = Object(); root.onRecord.listen((record) { messages.add('${record.level}: ${record.message}'); From 3f7c1139b63b2eb02e5d60fca342a65fd1c71663 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 06:52:01 +0000 Subject: [PATCH 147/163] Bump dart-lang/setup-dart from 1.6.1 to 1.6.2 (dart-lang/logging#157) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.1 to 1.6.2.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.2

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available in an environment variable, DART_HOME (dart-lang/logging#43).
  • Fixed an issue where cached downloads could lead to unzip issues on self-hosted runners (dart-lang/logging#35).

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.1&new-version=1.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 1e34fae8..3ca2c233 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install @@ -47,7 +47,7 @@ jobs: sdk: [3.2, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install From 3ae5f9a4819d57e2d5434028bae89ab85b3488dd Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 7 Mar 2024 14:43:59 -0800 Subject: [PATCH 148/163] Override empty stack traces for traced events (dart-lang/logging#158) We already default to the current stack trace of the logging caller when there is no stack trace available so the author has some signal for where to look in the code. Also default for non-null but empty stack traces. This is more useful where an empty trace was passed through some signature to satisfy nullability requirements and forwarded to the log. --- pkgs/logging/CHANGELOG.md | 3 ++- pkgs/logging/lib/src/logger.dart | 7 ++++++- pkgs/logging/pubspec.yaml | 2 +- pkgs/logging/test/logging_test.dart | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 41843d89..fa6646a8 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,5 +1,6 @@ -## 1.2.1-wip +## 1.3.0-wip +* Override empty stack traces for trace level events. * Require Dart 3.2 ## 1.2.0 diff --git a/pkgs/logging/lib/src/logger.dart b/pkgs/logging/lib/src/logger.dart index bf27f505..d9fa2544 100644 --- a/pkgs/logging/lib/src/logger.dart +++ b/pkgs/logging/lib/src/logger.dart @@ -202,6 +202,10 @@ class Logger { /// was made. This can be advantageous if a log listener wants to handler /// records of different zones differently (e.g. group log records by HTTP /// request if each HTTP request handler runs in it's own zone). + /// + /// If this record is logged at a level equal to or higher than + /// [recordStackTraceAtLevel] and [stackTrace] is `null` or [StackTrace.empty] + /// it will be defaulted to the current stack trace for this call. void log(Level logLevel, Object? message, [Object? error, StackTrace? stackTrace, Zone? zone]) { Object? object; @@ -218,7 +222,8 @@ class Logger { object = message; } - if (stackTrace == null && logLevel >= recordStackTraceAtLevel) { + if ((stackTrace == null || stackTrace == StackTrace.empty) && + logLevel >= recordStackTraceAtLevel) { stackTrace = StackTrace.current; error ??= 'autogenerated stack trace for $logLevel $msg'; } diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 6d05e986..bb3ff1a9 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.2.1-wip +version: 1.3.0-wip description: >- Provides APIs for debugging and error logging, similar to loggers in other languages, such as the Closure JS Logger and java.util.logging.Logger. diff --git a/pkgs/logging/test/logging_test.dart b/pkgs/logging/test/logging_test.dart index 7edabb08..6bff3d86 100644 --- a/pkgs/logging/test/logging_test.dart +++ b/pkgs/logging/test/logging_test.dart @@ -690,6 +690,22 @@ void main() { expect(records[2].stackTrace, isNull); }); + test('defaults a missing trace', () { + final records = []; + recordStackTraceAtLevel = Level.SEVERE; + root.onRecord.listen(records.add); + root.severe('hello'); + expect(records.single.stackTrace, isNotNull); + }); + + test('defaults an empty trace', () { + final records = []; + recordStackTraceAtLevel = Level.SEVERE; + root.onRecord.listen(records.add); + root.severe('hello', 'error', StackTrace.empty); + expect(records.single.stackTrace, isNot(StackTrace.empty)); + }); + test('provided trace is used if given', () { final trace = StackTrace.current; final records = []; From 0ddcee3e75feb2642327237aa943c10e73bd0533 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 06:58:21 +0000 Subject: [PATCH 149/163] Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/logging#160) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2.
Release notes

Sourced from actions/checkout's releases.

v4.1.2

We are investigating the following issue with this release and have rolled-back the v4 tag to point to v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.1...v4.1.2

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.1&new-version=4.1.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 3ca2c233..c9931891 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -21,7 +21,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest] sdk: [3.2, dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} From 0e3dbb659fbba06a3b26de84d65637ec11a9994d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 06:29:50 +0000 Subject: [PATCH 150/163] Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/logging#162) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.2 to 1.6.4.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.4

  • Rebuild JS code to include changes from v1.6.3

v1.6.3

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.2&new-version=1.6.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index c9931891..c0145dc1 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install @@ -47,7 +47,7 @@ jobs: sdk: [3.2, dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install From 8397ba07ab00c97c28e5760c37730d588e13b466 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 15:27:58 +0000 Subject: [PATCH 151/163] Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/logging#161) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.2 to 4.1.4.
Release notes

Sourced from actions/checkout's releases.

v4.1.4

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.3...v4.1.4

v4.1.3

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.2...v4.1.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.2&new-version=4.1.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index c0145dc1..9027aba8 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -21,7 +21,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest] sdk: [3.2, dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From c4b8ecf7aef06104bc48a4e01d5192c71faae4eb Mon Sep 17 00:00:00 2001 From: Jonas Finnemann Jensen Date: Thu, 30 May 2024 10:22:21 +0200 Subject: [PATCH 152/163] Add `topics` to `pubspec.yaml` (dart-lang/logging#164) --- pkgs/logging/pubspec.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index bb3ff1a9..abc34ce5 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -4,6 +4,8 @@ description: >- Provides APIs for debugging and error logging, similar to loggers in other languages, such as the Closure JS Logger and java.util.logging.Logger. repository: https://github.com/dart-lang/logging +topics: + - logging environment: sdk: ^3.2.0 From eacc9288fd461122ae92b989749bf64a1e4710d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jun 2024 06:42:20 +0000 Subject: [PATCH 153/163] Bump actions/checkout from 4.1.4 to 4.1.6 (dart-lang/logging#166) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.4 to 4.1.6.
Release notes

Sourced from actions/checkout's releases.

v4.1.6

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.5...v4.1.6

v4.1.5

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.4...v4.1.5

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.4&new-version=4.1.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 9027aba8..8ba14f7c 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -21,7 +21,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest] sdk: [3.2, dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From ddda561b196e6749313b3e5948f1a7e39308a4a2 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Tue, 4 Jun 2024 10:24:29 +0200 Subject: [PATCH 154/163] Update `topics` in `pubspec.yaml` (dart-lang/logging#165) --- pkgs/logging/pubspec.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index abc34ce5..47f19ca8 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -4,8 +4,10 @@ description: >- Provides APIs for debugging and error logging, similar to loggers in other languages, such as the Closure JS Logger and java.util.logging.Logger. repository: https://github.com/dart-lang/logging + topics: - logging + - debugging environment: sdk: ^3.2.0 From 8b5427b0b7d313ad94cc973ea4dc61aebaf7e83d Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 20 Jun 2024 09:21:08 -0700 Subject: [PATCH 155/163] Update lints dep, bump min SDK (dart-lang/logging#167) --- pkgs/logging/.github/workflows/test-package.yml | 2 +- pkgs/logging/CHANGELOG.md | 2 +- pkgs/logging/pubspec.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 8ba14f7c..13645331 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -44,7 +44,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [3.2, dev] + sdk: [3.4, dev] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index fa6646a8..37572b65 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,7 +1,7 @@ ## 1.3.0-wip * Override empty stack traces for trace level events. -* Require Dart 3.2 +* Require Dart 3.4 ## 1.2.0 diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index 47f19ca8..cc059c1d 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -10,8 +10,8 @@ topics: - debugging environment: - sdk: ^3.2.0 + sdk: ^3.4.0 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 test: ^1.16.0 From 456e9e79f7bacd4be8dc87513c113840c419a7e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 06:27:06 +0000 Subject: [PATCH 156/163] Bump actions/checkout from 4.1.6 to 4.1.7 (dart-lang/logging#168) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.1.7.
Release notes

Sourced from actions/checkout's releases.

v4.1.7

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.6...v4.1.7

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.6&new-version=4.1.7)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 13645331..8f7329a1 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -21,7 +21,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest] sdk: [3.4, dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From bba9edba2bd815a2d788c0f4d509c4bb78524321 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 1 Jul 2024 10:18:04 -0700 Subject: [PATCH 157/163] blast_repo fixes (dart-lang/logging#170) dependabot, github-actions, no-response --- pkgs/logging/.github/dependabot.yaml | 4 ++++ pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/dependabot.yaml b/pkgs/logging/.github/dependabot.yaml index 439e796b..bf6b38a4 100644 --- a/pkgs/logging/.github/dependabot.yaml +++ b/pkgs/logging/.github/dependabot.yaml @@ -8,3 +8,7 @@ updates: interval: monthly labels: - autosubmit + groups: + github-actions: + patterns: + - "*" diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 8f7329a1..859ec9b4 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install @@ -47,7 +47,7 @@ jobs: sdk: [3.4, dev] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install From 168f5417b6ae58be95da8e07f1e8f9b7125167d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 06:33:17 +0000 Subject: [PATCH 158/163] Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group (dart-lang/logging#172) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.7 to 4.2.0
Release notes

Sourced from actions/checkout's releases.

v4.2.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.7...v4.2.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.2.0

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.7&new-version=4.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/logging/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/logging/.github/workflows/test-package.yml b/pkgs/logging/.github/workflows/test-package.yml index 859ec9b4..3c6e7434 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/pkgs/logging/.github/workflows/test-package.yml @@ -21,7 +21,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest] sdk: [3.4, dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} From 77c93eb5e9383b46efd76366fb260b7a97d8d3f5 Mon Sep 17 00:00:00 2001 From: lawther Date: Fri, 4 Oct 2024 01:30:11 +1000 Subject: [PATCH 159/163] Fix typo in README (dart-lang/logging#173) --- pkgs/logging/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index 70f16604..c033972d 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -33,7 +33,7 @@ First, set the root `Level`. All messages at or above the current level are sent 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 notitfications use: +To listen for changed level notifications use: ```dart Logger.root.onLevelChanged.listen((level) { From bafb17e23241177dcdc9c8ae555cdded36af4aeb Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 16 Oct 2024 10:57:59 +0200 Subject: [PATCH 160/163] Add issue template and other fixes --- .github/ISSUE_TEMPLATE/logging.md | 5 +++++ pkgs/logging/pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/logging.md diff --git a/.github/ISSUE_TEMPLATE/logging.md b/.github/ISSUE_TEMPLATE/logging.md new file mode 100644 index 00000000..53564bc7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/logging.md @@ -0,0 +1,5 @@ +--- +name: "package:logging" +about: "Create a bug or file a feature request against package:logging." +labels: "package:logging" +--- \ No newline at end of file diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index cc059c1d..e3738cf7 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -3,7 +3,7 @@ version: 1.3.0-wip description: >- Provides APIs for debugging and error logging, similar to loggers in other languages, such as the Closure JS Logger and java.util.logging.Logger. -repository: https://github.com/dart-lang/logging +repository: https://github.com/dart-lang/core/tree/main/pkgs/logging topics: - logging From b3d67ea2258bb5fff2557cb13016c85a514260fb Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 16 Oct 2024 11:02:19 +0200 Subject: [PATCH 161/163] Moving fixes --- .github/labeler.yml | 4 ++ .../workflows/logging.yaml | 19 +++++++--- README.md | 1 + pkgs/logging/.github/dependabot.yaml | 14 ------- .../logging/.github/workflows/no-response.yml | 37 ------------------- pkgs/logging/.github/workflows/publish.yaml | 17 --------- pkgs/logging/CHANGELOG.md | 3 +- pkgs/logging/README.md | 7 +--- pkgs/logging/pubspec.yaml | 2 +- 9 files changed, 23 insertions(+), 81 deletions(-) rename pkgs/logging/.github/workflows/test-package.yml => .github/workflows/logging.yaml (82%) delete mode 100644 pkgs/logging/.github/dependabot.yaml delete mode 100644 pkgs/logging/.github/workflows/no-response.yml delete mode 100644 pkgs/logging/.github/workflows/publish.yaml diff --git a/.github/labeler.yml b/.github/labeler.yml index fc71da29..31e72c51 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -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/**' diff --git a/pkgs/logging/.github/workflows/test-package.yml b/.github/workflows/logging.yaml similarity index 82% rename from pkgs/logging/.github/workflows/test-package.yml rename to .github/workflows/logging.yaml index 3c6e7434..c8666412 100644 --- a/pkgs/logging/.github/workflows/test-package.yml +++ b/.github/workflows/logging.yaml @@ -1,17 +1,26 @@ -name: Dart CI +name: package:logging on: - # Run on PRs and pushes to the default branch. + # Run CI on pushes to the main branch, and on PRs against main. push: - branches: [ master ] + branches: [ main ] + paths: + - '.github/workflows/logging.yaml' + - 'pkgs/logging/**' pull_request: - branches: [ master ] + 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: diff --git a/README.md b/README.md index 77c5fdb3..7a6c0fda 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/pkgs/logging/.github/dependabot.yaml b/pkgs/logging/.github/dependabot.yaml deleted file mode 100644 index bf6b38a4..00000000 --- a/pkgs/logging/.github/dependabot.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# Dependabot configuration file. -version: 2 - -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: monthly - labels: - - autosubmit - groups: - github-actions: - patterns: - - "*" diff --git a/pkgs/logging/.github/workflows/no-response.yml b/pkgs/logging/.github/workflows/no-response.yml deleted file mode 100644 index ab1ac498..00000000 --- a/pkgs/logging/.github/workflows/no-response.yml +++ /dev/null @@ -1,37 +0,0 @@ -# A workflow to close issues where the author hasn't responded to a request for -# more information; see https://github.com/actions/stale. - -name: No Response - -# Run as a daily cron. -on: - schedule: - # Every day at 8am - - cron: '0 8 * * *' - -# All permissions not specified are set to 'none'. -permissions: - issues: write - pull-requests: write - -jobs: - no-response: - runs-on: ubuntu-latest - if: ${{ github.repository_owner == 'dart-lang' }} - steps: - - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e - with: - # Don't automatically mark inactive issues+PRs as stale. - days-before-stale: -1 - # Close needs-info issues and PRs after 14 days of inactivity. - days-before-close: 14 - stale-issue-label: "needs-info" - close-issue-message: > - Without additional information we're not able to resolve this issue. - Feel free to add more info or respond to any questions above and we - can reopen the case. Thanks for your contribution! - stale-pr-label: "needs-info" - close-pr-message: > - Without additional information we're not able to resolve this PR. - Feel free to add more info or respond to any questions above. - Thanks for your contribution! diff --git a/pkgs/logging/.github/workflows/publish.yaml b/pkgs/logging/.github/workflows/publish.yaml deleted file mode 100644 index 27157a04..00000000 --- a/pkgs/logging/.github/workflows/publish.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# A CI configuration to auto-publish pub packages. - -name: Publish - -on: - pull_request: - branches: [ master ] - push: - tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] - -jobs: - publish: - if: ${{ github.repository_owner == 'dart-lang' }} - uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main - permissions: - id-token: write # Required for authentication using OIDC - pull-requests: write # Required for writing the pull request note diff --git a/pkgs/logging/CHANGELOG.md b/pkgs/logging/CHANGELOG.md index 37572b65..088183c9 100644 --- a/pkgs/logging/CHANGELOG.md +++ b/pkgs/logging/CHANGELOG.md @@ -1,7 +1,8 @@ -## 1.3.0-wip +## 1.3.0 * Override empty stack traces for trace level events. * Require Dart 3.4 +* Move to `dart-lang/core` monorepo. ## 1.2.0 diff --git a/pkgs/logging/README.md b/pkgs/logging/README.md index c033972d..66231450 100644 --- a/pkgs/logging/README.md +++ b/pkgs/logging/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://github.com/dart-lang/logging/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/logging/actions?query=workflow%3A"Dart+CI"+branch%3Amaster) +[![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) @@ -139,8 +139,3 @@ Results in: [LOG2][WARNING+] LOG_02 WARNING (√√) [ROOT][WARNING+] LOG_02 WARNING (√√) ``` - -## Publishing automation - -For information about our publishing automation and release process, see -https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. diff --git a/pkgs/logging/pubspec.yaml b/pkgs/logging/pubspec.yaml index e3738cf7..8fb8a436 100644 --- a/pkgs/logging/pubspec.yaml +++ b/pkgs/logging/pubspec.yaml @@ -1,5 +1,5 @@ name: logging -version: 1.3.0-wip +version: 1.3.0 description: >- Provides APIs for debugging and error logging, similar to loggers in other languages, such as the Closure JS Logger and java.util.logging.Logger. From 31caf599366db5789c54ad8a7919cb47c3bf7ff2 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 16 Oct 2024 11:03:10 +0200 Subject: [PATCH 162/163] Add license to example file --- pkgs/logging/example/main.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/logging/example/main.dart b/pkgs/logging/example/main.dart index e40d27be..b565c3c1 100644 --- a/pkgs/logging/example/main.dart +++ b/pkgs/logging/example/main.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// 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. + import 'package:logging/logging.dart'; final log = Logger('ExampleLogger'); From 63e934ca51d97b70b1a1a892e05b090c636bcfa3 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 16 Oct 2024 12:23:52 -0700 Subject: [PATCH 163/163] contribute a issue template for package:args (#139) --- .github/ISSUE_TEMPLATE/args.md | 5 +++++ CONTRIBUTING.md | 4 ++-- pkgs/args/example/arg_parser/pubspec.yaml | 4 +++- pkgs/args/example/command_runner/pubspec.yaml | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/args.md diff --git a/.github/ISSUE_TEMPLATE/args.md b/.github/ISSUE_TEMPLATE/args.md new file mode 100644 index 00000000..0a99d177 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/args.md @@ -0,0 +1,5 @@ +--- +name: "package:args" +about: "Create a bug or file a feature request against package:args." +labels: "package:args" +--- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e4646827..5b4fcef5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,7 +38,7 @@ new file please also add this. The year should be a single number stating the year the file was created (don't use a range like "2011-2012"). Additionally, if you edit an existing file, you shouldn't update the year. - // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file + // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file // 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. @@ -48,4 +48,4 @@ This project follows [Google's Open Source Community Guidelines](https://opensource.google/conduct/). We pledge to maintain an open and welcoming environment. For details, see our -[code of conduct](https://dart.dev/code-of-conduct). \ No newline at end of file +[code of conduct](https://dart.dev/code-of-conduct). diff --git a/pkgs/args/example/arg_parser/pubspec.yaml b/pkgs/args/example/arg_parser/pubspec.yaml index 52f193a8..9cb1cbdc 100644 --- a/pkgs/args/example/arg_parser/pubspec.yaml +++ b/pkgs/args/example/arg_parser/pubspec.yaml @@ -6,8 +6,10 @@ name: arg_parser_example version: 1.0.0 description: An example of using ArgParser publish_to: 'none' + environment: - sdk: '>=2.14.0 <3.0.0' + sdk: ^3.0.0 + dependencies: args: path: ../.. diff --git a/pkgs/args/example/command_runner/pubspec.yaml b/pkgs/args/example/command_runner/pubspec.yaml index 0745be61..636b4641 100644 --- a/pkgs/args/example/command_runner/pubspec.yaml +++ b/pkgs/args/example/command_runner/pubspec.yaml @@ -6,8 +6,10 @@ name: command_runner_example version: 1.0.0 description: An example of using CommandRunner publish_to: 'none' + environment: - sdk: '>=2.14.0 <3.0.0' + sdk: ^3.0.0 + dependencies: args: path: ../..