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

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

Issue 413193002: pkg/logging: use UnmodifiableMapView from dart:collection (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: removed initial line Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « pkg/logging/README.md ('k') | pkg/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 * Support for logging.
7 *
8 * For information on installing and importing this library, see the
9 * [logging package on pub.dartlang.org]
10 * (http://pub.dartlang.org/packages/logging).
11 *
12 * ## Initializing
13 *
14 * By default, the logging package does not do anything useful with the
15 * log messages. You must configure the logging level and add a handler
16 * for the log messages.
17 *
18 * Here is a simple logging configuration that logs all messages
19 * via `print`.
20 *
21 * Logger.root.level = Level.ALL;
22 * Logger.root.onRecord.listen((LogRecord rec) {
23 * print('${rec.level.name}: ${rec.time}: ${rec.message}');
24 * });
25 *
26 * First, set the root [Level]. All messages at or above the level are
27 * sent to the [onRecord] stream.
28 *
29 * Then, listen on the [onRecord] stream for [LogRecord] events. The
30 * [LogRecord] class has various properties for the message, error,
31 * logger name, and more.
32 *
33 * ## Logging messages
34 *
35 * Create a [Logger] with a unique name to easily identify the source
36 * of the log messages.
37 *
38 * final Logger log = new Logger('MyClassName');
39 *
40 * Here is an example of logging a debug message and an error:
41 *
42 * Future future = doSomethingAsync();
43 * future.then((result) {
44 * log.fine('Got the result: $result');
45 * processResult(result);
46 * })
47 * .catchError((e, stackTrace) => log.severe('Oh noes!', e, stackTrace));
48 *
49 * See the [Logger] class for the different logging methods.
50 */ 6 */
51 library logging; 7 library logging;
52 8
53 import 'dart:async'; 9 import 'dart:async';
54 import 'package:collection/wrappers.dart'; 10 import 'dart:collection';
55 11
56 /** 12 /**
57 * Whether to allow fine-grain logging and configuration of loggers in a 13 * Whether to allow fine-grain logging and configuration of loggers in a
58 * hierarchy. When false, all logging is merged in the root logger. 14 * hierarchy. When false, all logging is merged in the root logger.
59 */ 15 */
60 bool hierarchicalLoggingEnabled = false; 16 bool hierarchicalLoggingEnabled = false;
61 17
62 /** 18 /**
63 * Level for the root-logger. This will be the level of all loggers if 19 * Level for the root-logger. This will be the level of all loggers if
64 * [hierarchicalLoggingEnabled] is false. 20 * [hierarchicalLoggingEnabled] is false.
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 /** Associated stackTrace (if any) when recording errors messages. */ 306 /** Associated stackTrace (if any) when recording errors messages. */
351 final StackTrace stackTrace; 307 final StackTrace stackTrace;
352 308
353 LogRecord(this.level, this.message, this.loggerName, [this.error, 309 LogRecord(this.level, this.message, this.loggerName, [this.error,
354 this.stackTrace]) 310 this.stackTrace])
355 : time = new DateTime.now(), 311 : time = new DateTime.now(),
356 sequenceNumber = LogRecord._nextNumber++; 312 sequenceNumber = LogRecord._nextNumber++;
357 313
358 String toString() => '[${level.name}] $loggerName: $message'; 314 String toString() => '[${level.name}] $loggerName: $message';
359 } 315 }
OLDNEW
« no previous file with comments | « pkg/logging/README.md ('k') | pkg/logging/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698