| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 /** |
| 6 * A utility class used to write logging information during a test. |
| 7 */ |
| 8 class Logger { |
| 9 /** |
| 10 * The width of the field in which labels are printed. |
| 11 */ |
| 12 static const int _labelWidth = 8; |
| 13 |
| 14 /** |
| 15 * The separator used to separate the label from the content. |
| 16 */ |
| 17 static const String _separator = ' : '; |
| 18 |
| 19 /** |
| 20 * The sink to which the logged information should be written. |
| 21 */ |
| 22 final StringSink sink; |
| 23 |
| 24 /** |
| 25 * Initialize a newly created logger to write to the given [sink]. |
| 26 */ |
| 27 Logger(this.sink); |
| 28 |
| 29 /** |
| 30 * Log the given information. |
| 31 * |
| 32 * The [label] is used to indicate the kind of information being logged, while |
| 33 * the [content] contains the actual information. If a list of [arguments] is |
| 34 * provided, then they will be written after the content. |
| 35 */ |
| 36 void log(String label, String content, {List<String> arguments = null}) { |
| 37 for (int i = _labelWidth - label.length; i > 0; i--) { |
| 38 sink.write(' '); |
| 39 } |
| 40 sink.write(label); |
| 41 sink.write(_separator); |
| 42 sink.write(content); |
| 43 arguments?.forEach((String argument) { |
| 44 sink.write(' '); |
| 45 sink.write(argument); |
| 46 }); |
| 47 sink.writeln(); |
| 48 } |
| 49 } |
| OLD | NEW |