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

Side by Side Diff: pkg/logging/README.md

Issue 413193002: pkg/logging: use UnmodifiableMapView from dart:collection (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | « no previous file | pkg/logging/lib/logging.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 Support for logging.
sethladd 2014/07/24 16:48:13 Nit: start line with # ?
kevmoo 2014/07/24 17:44:18 Done.
2
sethladd 2014/07/24 16:48:13 READMEs often include notes about where to file bu
kevmoo 2014/07/24 17:44:18 There's already a license file in the package. We
3 ## Initializing
4
5 By default, the logging package does not do anything useful with the
6 log messages. You must configure the logging level and add a handler
7 for the log messages.
8
9 Here is a simple logging configuration that logs all messages
10 via `print`.
11
12 ```dart
13 Logger.root.level = Level.ALL;
14 Logger.root.onRecord.listen((LogRecord rec) {
15 print('${rec.level.name}: ${rec.time}: ${rec.message}');
16 });
17 ```
18
19 First, set the root [Level]. All messages at or above the level are
20 sent to the [onRecord] stream.
21
22 Then, listen on the [onRecord] stream for [LogRecord] events. The
23 [LogRecord] class has various properties for the message, error,
24 logger name, and more.
25
26 ## Logging messages
27
28 Create a [Logger] with a unique name to easily identify the source
29 of the log messages.
30
31 ```dart
32 final Logger log = new Logger('MyClassName');
33 ```
34
35 Here is an example of logging a debug message and an error:
36
37 ```dart
38 var future = doSomethingAsync().then((result) {
39 log.fine('Got the result: $result');
40 processResult(result);
41 }).catchError((e, stackTrace) => log.severe('Oh noes!', e, stackTrace));
42 ```
43
44 See the [Logger] class for the different logging methods.
OLDNEW
« no previous file with comments | « no previous file | pkg/logging/lib/logging.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698