| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 /// Logs the spawning of an [executable] process with [arguments] at [IO] | 110 /// Logs the spawning of an [executable] process with [arguments] at [IO] |
| 111 /// level. | 111 /// level. |
| 112 void process(String executable, List<String> arguments) { | 112 void process(String executable, List<String> arguments) { |
| 113 io("Spawning $executable ${arguments.join(' ')}"); | 113 io("Spawning $executable ${arguments.join(' ')}"); |
| 114 } | 114 } |
| 115 | 115 |
| 116 /// Logs the results of running [executable]. | 116 /// Logs the results of running [executable]. |
| 117 void processResult(String executable, PubProcessResult result) { | 117 void processResult(String executable, PubProcessResult result) { |
| 118 // Log it all as one message so that it shows up as a single unit in the logs. | 118 // Log it all as one message so that it shows up as a single unit in the logs. |
| 119 var buffer = new StringBuffer(); | 119 var buffer = new StringBuffer(); |
| 120 buffer.add("Finished $executable. Exit code ${result.exitCode}."); | 120 buffer.write("Finished $executable. Exit code ${result.exitCode}."); |
| 121 | 121 |
| 122 dumpOutput(String name, List<String> output) { | 122 dumpOutput(String name, List<String> output) { |
| 123 if (output.length == 0) { | 123 if (output.length == 0) { |
| 124 buffer.add("Nothing output on $name."); | 124 buffer.write("Nothing output on $name."); |
| 125 } else { | 125 } else { |
| 126 buffer.add("$name:"); | 126 buffer.write("$name:"); |
| 127 var numLines = 0; | 127 var numLines = 0; |
| 128 for (var line in output) { | 128 for (var line in output) { |
| 129 if (++numLines > 1000) { | 129 if (++numLines > 1000) { |
| 130 buffer.add('[${output.length - 1000}] more lines of output ' | 130 buffer.write('[${output.length - 1000}] more lines of output ' |
| 131 'truncated...]'); | 131 'truncated...]'); |
| 132 break; | 132 break; |
| 133 } | 133 } |
| 134 | 134 |
| 135 buffer.add(line); | 135 buffer.write(line); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 dumpOutput("stdout", result.stdout); | 140 dumpOutput("stdout", result.stdout); |
| 141 dumpOutput("stderr", result.stderr); | 141 dumpOutput("stderr", result.stderr); |
| 142 | 142 |
| 143 io(buffer.toString()); | 143 io(buffer.toString()); |
| 144 } | 144 } |
| 145 | 145 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 sink.add(' | '.codeUnits); | 219 sink.add(' | '.codeUnits); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 sink.add(line.codeUnits); | 223 sink.add(line.codeUnits); |
| 224 sink.add('\n'.codeUnits); | 224 sink.add('\n'.codeUnits); |
| 225 | 225 |
| 226 firstLine = false; | 226 firstLine = false; |
| 227 } | 227 } |
| 228 } | 228 } |
| OLD | NEW |