OLD | NEW |
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 * Provides APIs for debugging and error logging. This library introduces | 6 * Provides APIs for debugging and error logging. This library introduces |
7 * abstractions similar to those used in other languages, such as the Closure JS | 7 * abstractions similar to those used in other languages, such as the Closure JS |
8 * Logger and java.util.logging.Logger. | 8 * Logger and java.util.logging.Logger. |
9 * | 9 * |
10 * ## Installing ## | 10 * ## Installing ## |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 void severe(String message, [exception]) => | 196 void severe(String message, [exception]) => |
197 log(Level.SEVERE, message, exception); | 197 log(Level.SEVERE, message, exception); |
198 | 198 |
199 /** Log message at level [Level.SHOUT]. */ | 199 /** Log message at level [Level.SHOUT]. */ |
200 void shout(String message, [exception]) => | 200 void shout(String message, [exception]) => |
201 log(Level.SHOUT, message, exception); | 201 log(Level.SHOUT, message, exception); |
202 | 202 |
203 Stream<LogRecord> _getStream() { | 203 Stream<LogRecord> _getStream() { |
204 if (hierarchicalLoggingEnabled || parent == null) { | 204 if (hierarchicalLoggingEnabled || parent == null) { |
205 if (_controller == null) { | 205 if (_controller == null) { |
206 _controller = new StreamController<LogRecord>(sync: true); | 206 _controller = new StreamController<LogRecord>.broadcast(sync: true); |
207 _stream = _controller.stream.asBroadcastStream(); | 207 _stream = _controller.stream; |
208 } | 208 } |
209 return _stream; | 209 return _stream; |
210 } else { | 210 } else { |
211 return root._getStream(); | 211 return root._getStream(); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 void _publish(LogRecord record) { | 215 void _publish(LogRecord record) { |
216 if (_controller != null) { | 216 if (_controller != null) { |
217 _controller.add(record); | 217 _controller.add(record); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 314 |
315 static int _nextNumber = 0; | 315 static int _nextNumber = 0; |
316 | 316 |
317 /** Associated exception (if any) when recording errors messages. */ | 317 /** Associated exception (if any) when recording errors messages. */ |
318 var exception; | 318 var exception; |
319 | 319 |
320 LogRecord(this.level, this.message, this.loggerName, [this.exception]) | 320 LogRecord(this.level, this.message, this.loggerName, [this.exception]) |
321 : time = new DateTime.now(), | 321 : time = new DateTime.now(), |
322 sequenceNumber = LogRecord._nextNumber++; | 322 sequenceNumber = LogRecord._nextNumber++; |
323 } | 323 } |
OLD | NEW |