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

Unified Diff: pkg/analysis_server/lib/http_server.dart

Issue 686763004: Allow print() to be used for debugging analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/driver.dart ('k') | pkg/analysis_server/lib/src/get_handler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/http_server.dart
diff --git a/pkg/analysis_server/lib/http_server.dart b/pkg/analysis_server/lib/http_server.dart
index 1fbd0afcc4ed25f1b8488efd2636c720a4ad78b7..a56cd507166cc326f04c8a603b29fa8dee89ca56 100644
--- a/pkg/analysis_server/lib/http_server.dart
+++ b/pkg/analysis_server/lib/http_server.dart
@@ -18,6 +18,11 @@ import 'package:analysis_server/src/socket_server.dart';
*/
class HttpAnalysisServer {
/**
+ * Number of lines of print output to capture.
+ */
+ static const int PRINT_BUFFER_LENGTH = 1000;
danrubel 2014/10/28 21:01:02 MAX_PRINT_BUFFER_MAX_LENGTH ?
Paul Berry 2014/10/28 23:29:13 Done.
+
+ /**
* An object that can handle either a WebSocket connection or a connection
* to the client over stdio.
*/
@@ -39,6 +44,11 @@ class HttpAnalysisServer {
Future<HttpServer> _server;
/**
+ * Last PRINT_BUFFER_LENGTH lines printed.
+ */
+ List<String> _printBuffer = <String>[];
+
+ /**
* Attach a listener to a newly created HTTP server.
*/
void _handleServer(HttpServer httServer) {
@@ -61,7 +71,7 @@ class HttpAnalysisServer {
*/
void _handleGetRequest(HttpRequest request) {
if (getHandler == null) {
- getHandler = new GetHandler(socketServer);
+ getHandler = new GetHandler(socketServer, _printBuffer);
}
getHandler.handleGetRequest(request);
}
@@ -99,4 +109,14 @@ class HttpAnalysisServer {
server.close();
});
}
+
+ /**
+ * Record that the given line was printed out by the analysis server.
+ */
+ void recordPrint(String line) {
+ _printBuffer.add(line);
+ if (_printBuffer.length > PRINT_BUFFER_LENGTH) {
+ _printBuffer.removeRange(0, _printBuffer.length - PRINT_BUFFER_LENGTH);
+ }
+ }
}
« no previous file with comments | « pkg/analysis_server/lib/driver.dart ('k') | pkg/analysis_server/lib/src/get_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698