| 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 /// Message logging. | 5 /// Message logging. |
| 6 library log; | 6 library log; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'io.dart'; | 9 import 'io.dart'; |
| 10 | 10 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 /// Log function that prints the message to stderr. | 201 /// Log function that prints the message to stderr. |
| 202 void _logToStderr(Entry entry) { | 202 void _logToStderr(Entry entry) { |
| 203 _logToStream(stderrSink, entry, showLabel: false); | 203 _logToStream(stderrSink, entry, showLabel: false); |
| 204 } | 204 } |
| 205 | 205 |
| 206 /// Log function that prints the message to stderr with the level name. | 206 /// Log function that prints the message to stderr with the level name. |
| 207 void _logToStderrWithLabel(Entry entry) { | 207 void _logToStderrWithLabel(Entry entry) { |
| 208 _logToStream(stderrSink, entry, showLabel: true); | 208 _logToStream(stderrSink, entry, showLabel: true); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void _logToStream(Sink<List<int>> sink, Entry entry, {bool showLabel}) { | 211 void _logToStream(StreamSink<List<int>> sink, Entry entry, {bool showLabel}) { |
| 212 bool firstLine = true; | 212 bool firstLine = true; |
| 213 for (var line in entry.lines) { | 213 for (var line in entry.lines) { |
| 214 if (showLabel) { | 214 if (showLabel) { |
| 215 if (firstLine) { | 215 if (firstLine) { |
| 216 sink.add(entry.level.name.charCodes); | 216 sink.add(entry.level.name.charCodes); |
| 217 sink.add(': '.charCodes); | 217 sink.add(': '.charCodes); |
| 218 } else { | 218 } else { |
| 219 sink.add(' | '.charCodes); | 219 sink.add(' | '.charCodes); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 sink.add(line.charCodes); | 223 sink.add(line.charCodes); |
| 224 sink.add('\n'.charCodes); | 224 sink.add('\n'.charCodes); |
| 225 | 225 |
| 226 firstLine = false; | 226 firstLine = false; |
| 227 } | 227 } |
| 228 } | 228 } |
| OLD | NEW |