Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: lib/src/command/serve.dart

Issue 1267023002: Collapse successful GET messages together. (Closed) Base URL: https://github.com/dart-lang/pub.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/log.dart » ('j') | lib/src/log.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library pub.command.serve; 5 library pub.command.serve;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 var prefix = log.gray( 151 var prefix = log.gray(
152 padRight("[${server.rootDirectory}]", directoryLength + 2)); 152 padRight("[${server.rootDirectory}]", directoryLength + 2));
153 153
154 server.results.listen((result) { 154 server.results.listen((result) {
155 var buffer = new StringBuffer(); 155 var buffer = new StringBuffer();
156 buffer.write("$prefix "); 156 buffer.write("$prefix ");
157 157
158 if (result.isSuccess) { 158 if (result.isSuccess) {
159 buffer.write( 159 buffer.write(
160 "${log.green('GET')} ${result.url.path} $_arrow ${result.id}"); 160 "${log.green('GET')} ${result.url.path} $_arrow ${result.id}");
161 log.collapsible(buffer);
161 } else { 162 } else {
162 buffer.write("${log.red('GET')} ${result.url.path} $_arrow"); 163 buffer.write("${log.red('GET')} ${result.url.path} $_arrow");
163 164
164 var error = result.error.toString(); 165 var error = result.error.toString();
165 if (error.contains("\n")) { 166 if (error.contains("\n")) {
166 buffer.write("\n${prefixLines(error)}"); 167 buffer.write("\n${prefixLines(error)}");
167 } else { 168 } else {
168 buffer.write(" $error"); 169 buffer.write(" $error");
169 } 170 }
171
172 log.error(buffer);
170 } 173 }
171
172 log.message(buffer);
173 }, onError: _fatalError); 174 }, onError: _fatalError);
174 175
175 log.message("Serving ${entrypoint.root.name} " 176 log.message("Serving ${entrypoint.root.name} "
176 "${padRight(server.rootDirectory, directoryLength)} " 177 "${padRight(server.rootDirectory, directoryLength)} "
177 "on ${log.bold('http://$hostname:${server.port}')}"); 178 "on ${log.bold('http://$hostname:${server.port}')}");
178 } 179 }
179 180
180 /// Reports [error] and exits the server. 181 /// Reports [error] and exits the server.
181 void _fatalError(error, [stackTrace]) { 182 void _fatalError(error, [stackTrace]) {
182 if (_completer.isCompleted) return; 183 if (_completer.isCompleted) return;
183 _completer.completeError(error, stackTrace); 184 _completer.completeError(error, stackTrace);
184 } 185 }
185 } 186 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/log.dart » ('j') | lib/src/log.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698