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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 /** Log message at level [Level.SEVERE]. */ | 190 /** Log message at level [Level.SEVERE]. */ |
191 void severe(String message) => log(Level.SEVERE, message); | 191 void severe(String message) => log(Level.SEVERE, message); |
192 | 192 |
193 /** Log message at level [Level.SHOUT]. */ | 193 /** Log message at level [Level.SHOUT]. */ |
194 void shout(String message) => log(Level.SHOUT, message); | 194 void shout(String message) => log(Level.SHOUT, message); |
195 | 195 |
196 Stream<LogRecord> _getStream() { | 196 Stream<LogRecord> _getStream() { |
197 if (hierarchicalLoggingEnabled || parent == null) { | 197 if (hierarchicalLoggingEnabled || parent == null) { |
198 if (_controller == null) { | 198 if (_controller == null) { |
199 _controller = new StreamController<LogRecord>(); | 199 _controller = new StreamController<LogRecord>(sync: true); |
200 _stream = _controller.stream.asBroadcastStream(); | 200 _stream = _controller.stream.asBroadcastStream(); |
201 } | 201 } |
202 return _stream; | 202 return _stream; |
203 } else { | 203 } else { |
204 return root._getStream(); | 204 return root._getStream(); |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 void _publish(LogRecord record) { | 208 void _publish(LogRecord record) { |
209 if (_controller != null) { | 209 if (_controller != null) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 312 |
313 /** Associated exception message (if any) when recording errors messages. */ | 313 /** Associated exception message (if any) when recording errors messages. */ |
314 String exceptionText; | 314 String exceptionText; |
315 | 315 |
316 LogRecord( | 316 LogRecord( |
317 this.level, this.message, this.loggerName, | 317 this.level, this.message, this.loggerName, |
318 [time, this.exception, this.exceptionText]) : | 318 [time, this.exception, this.exceptionText]) : |
319 this.time = (time == null) ? new DateTime.now() : time, | 319 this.time = (time == null) ? new DateTime.now() : time, |
320 this.sequenceNumber = LogRecord._nextNumber++; | 320 this.sequenceNumber = LogRecord._nextNumber++; |
321 } | 321 } |
OLD | NEW |