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

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

Issue 774983003: Add logging to the incremental resolver. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Extract logger into a separate library. Remove dart:io dependency. Created 6 years 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
Index: pkg/analysis_server/lib/driver.dart
diff --git a/pkg/analysis_server/lib/driver.dart b/pkg/analysis_server/lib/driver.dart
index 74f1dcd8b0e7cbc915b9f459b2219dee79d0044e..b49e761c4fdf281eadec8e06d8b6f52bca082cca 100644
--- a/pkg/analysis_server/lib/driver.dart
+++ b/pkg/analysis_server/lib/driver.dart
@@ -11,11 +11,39 @@ import 'package:analysis_server/http_server.dart';
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/socket_server.dart';
import 'package:analysis_server/stdio_server.dart';
+import 'package:analyzer/src/generated/incremental_logger.dart';
import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/sdk_io.dart';
import 'package:args/args.dart';
+
+/**
+ * Initializes incremental logger.
+ *
+ * Supports following formats of [spec]:
+ *
+ * "console" - log to the console;
+ * "file:/some/file/name" - log to the file, overwritten on start.
+ */
+void _initIncrementalLogger(String spec) {
+ logger = new NullLogger();
+ if (spec == null) {
+ return;
+ }
+ // create logger
+ if (spec == 'console') {
+ logger = new StringSinkLogger(console.log);
+ }
+ if (spec.startsWith('file:')) {
+ String fileName = spec.substring('file:'.length);
+ File file = new File(fileName);
+ IOSink sink = file.openWrite();
+ logger = new StringSinkLogger(sink);
+ }
+}
+
+
/**
* The [Driver] class represents a single running instance of the analysis
* server application. It is responsible for parsing command line options
@@ -34,6 +62,11 @@ class Driver {
"enable-incremental-resolution";
/**
+ * The name of the option used to describe the incremental resolution logger.
+ */
+ static const String INCREMENTAL_RESOLUTION_LOG = "incremental-resolution-log";
+
+ /**
* The name of the option used to enable instrumentation.
*/
static const String ENABLE_INSTRUMENTATION_OPTION = "enable-instrumentation";
@@ -54,8 +87,7 @@ class Driver {
* The name of the option used to specify if [print] should print to the
* console instead of being intercepted.
*/
- static const String INTERNAL_PRINT_TO_CONSOLE =
- "internal-print-to-console";
+ static const String INTERNAL_PRINT_TO_CONSOLE = "internal-print-to-console";
/**
* The name of the option used to specify the port to which the server will
@@ -103,6 +135,9 @@ class Driver {
defaultsTo: false,
negatable: false);
parser.addOption(
+ INCREMENTAL_RESOLUTION_LOG,
+ help: "the description of the incremental resolotion log");
+ parser.addOption(
INSTRUMENTATION_LOG_FILE_OPTION,
help: "[path] the file to which instrumentation data will be logged");
parser.addFlag(
@@ -155,6 +190,8 @@ class Driver {
analysisServerOptions.enableIncrementalResolution =
results[ENABLE_INCREMENTAL_RESOLUTION];
+ _initIncrementalLogger(results[INCREMENTAL_RESOLUTION_LOG]);
+
DartSdk defaultSdk;
if (results[SDK_OPTION] != null) {
defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION]));

Powered by Google App Engine
This is Rietveld 408576698