Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: packages/logging/lib/logging.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packages/logging/codereview.settings ('k') | packages/logging/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 */ 6 */
7 library logging; 7 library logging;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 StreamController<LogRecord> _controller; 54 StreamController<LogRecord> _controller;
55 55
56 /** 56 /**
57 * Singleton constructor. Calling `new Logger(name)` will return the same 57 * Singleton constructor. Calling `new Logger(name)` will return the same
58 * actual instance whenever it is called with the same string name. 58 * actual instance whenever it is called with the same string name.
59 */ 59 */
60 factory Logger(String name) { 60 factory Logger(String name) {
61 return _loggers.putIfAbsent(name, () => new Logger._named(name)); 61 return _loggers.putIfAbsent(name, () => new Logger._named(name));
62 } 62 }
63 63
64 /// Creates a new detached [Logger].
65 ///
66 /// Returns a new [Logger] instance (unlike `new Logger`, which returns a
67 /// [Logger] singleton), which doesn't have any parent or children,
68 /// and it's not a part of the global hierarchial loggers structure.
69 ///
70 /// It can be useful when you just need a local short-living logger,
71 /// which you'd like to be garbage-collected later.
72 factory Logger.detached(String name) {
73 return new Logger._internal(name, null, new Map<String, Logger>());
74 }
75
64 factory Logger._named(String name) { 76 factory Logger._named(String name) {
65 if (name.startsWith('.')) { 77 if (name.startsWith('.')) {
66 throw new ArgumentError("name shouldn't start with a '.'"); 78 throw new ArgumentError("name shouldn't start with a '.'");
67 } 79 }
68 // Split hierarchical names (separated with '.'). 80 // Split hierarchical names (separated with '.').
69 int dot = name.lastIndexOf('.'); 81 int dot = name.lastIndexOf('.');
70 Logger parent = null; 82 Logger parent = null;
71 String thisName; 83 String thisName;
72 if (dot == -1) { 84 if (dot == -1) {
73 if (name != '') parent = new Logger(''); 85 if (name != '') parent = new Logger('');
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 /** Zone of the calling code which resulted in this LogRecord. */ 355 /** Zone of the calling code which resulted in this LogRecord. */
344 final Zone zone; 356 final Zone zone;
345 357
346 LogRecord(this.level, this.message, this.loggerName, 358 LogRecord(this.level, this.message, this.loggerName,
347 [this.error, this.stackTrace, this.zone]) 359 [this.error, this.stackTrace, this.zone])
348 : time = new DateTime.now(), 360 : time = new DateTime.now(),
349 sequenceNumber = LogRecord._nextNumber++; 361 sequenceNumber = LogRecord._nextNumber++;
350 362
351 String toString() => '[${level.name}] $loggerName: $message'; 363 String toString() => '[${level.name}] $loggerName: $message';
352 } 364 }
OLDNEW
« no previous file with comments | « packages/logging/codereview.settings ('k') | packages/logging/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698