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

Unified Diff: pkg/analysis_server/lib/driver.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 | « no previous file | pkg/analysis_server/lib/http_server.dart » ('j') | pkg/analysis_server/lib/http_server.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/driver.dart
diff --git a/pkg/analysis_server/lib/driver.dart b/pkg/analysis_server/lib/driver.dart
index ca278c7e816b26619aeb602251e9ba2a72856e6a..597dc1962789c8db1a846aaee3aa1cddf67aa05b 100644
--- a/pkg/analysis_server/lib/driver.dart
+++ b/pkg/analysis_server/lib/driver.dart
@@ -4,6 +4,7 @@
library driver;
+import 'dart:async';
import 'dart:io';
import 'package:analysis_server/http_server.dart';
@@ -125,12 +126,28 @@ class Driver {
if (serve_http) {
httpServer.serveHttp(port);
}
- stdioServer.serveStdio().then((_) {
- if (serve_http) {
- httpServer.close();
- }
- exit(0);
+ _capturePrints(() {
+ stdioServer.serveStdio().then((_) {
+ if (serve_http) {
+ httpServer.close();
+ }
+ exit(0);
+ });
+ }, httpServer.recordPrint);
+ }
+
+ /**
+ * Execute [callback], capturing any data it prints out and redirecting it to
+ * the function [printHandler].
+ */
+ dynamic _capturePrints(dynamic callback(), void printHandler(String line)) {
+ ZoneSpecification zoneSpecification = new ZoneSpecification(print:
+ (Zone self, ZoneDelegate parent, Zone zone, String line) {
+ printHandler(line);
+ // Note: we don't pass the line on to stdout, because that is reserved
+ // for communication to the client.
});
+ return runZoned(callback, zoneSpecification: zoneSpecification);
}
/**
« no previous file with comments | « no previous file | pkg/analysis_server/lib/http_server.dart » ('j') | pkg/analysis_server/lib/http_server.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698