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

Side by Side Diff: pkg/analysis_server/lib/src/server/driver.dart

Issue 950983002: Add support for writing instrumentation to a log file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 driver; 5 library driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:math'; 9 import 'dart:math';
10 10
11 import 'package:analysis_server/plugin/plugin.dart'; 11 import 'package:analysis_server/plugin/plugin.dart';
12 import 'package:analysis_server/src/analysis_server.dart'; 12 import 'package:analysis_server/src/analysis_server.dart';
13 import 'package:analysis_server/src/plugin/plugin_impl.dart'; 13 import 'package:analysis_server/src/plugin/plugin_impl.dart';
14 import 'package:analysis_server/src/plugin/server_plugin.dart'; 14 import 'package:analysis_server/src/plugin/server_plugin.dart';
15 import 'package:analysis_server/src/server/http_server.dart'; 15 import 'package:analysis_server/src/server/http_server.dart';
16 import 'package:analysis_server/src/server/stdio_server.dart'; 16 import 'package:analysis_server/src/server/stdio_server.dart';
17 import 'package:analysis_server/src/socket_server.dart'; 17 import 'package:analysis_server/src/socket_server.dart';
18 import 'package:analysis_server/starter.dart'; 18 import 'package:analysis_server/starter.dart';
19 import 'package:analyzer/file_system/physical_file_system.dart'; 19 import 'package:analyzer/file_system/physical_file_system.dart';
20 import 'package:analyzer/instrumentation/file_instrumentation.dart';
20 import 'package:analyzer/instrumentation/instrumentation.dart'; 21 import 'package:analyzer/instrumentation/instrumentation.dart';
21 import 'package:analyzer/src/generated/engine.dart'; 22 import 'package:analyzer/src/generated/engine.dart';
22 import 'package:analyzer/src/generated/incremental_logger.dart'; 23 import 'package:analyzer/src/generated/incremental_logger.dart';
23 import 'package:analyzer/src/generated/java_io.dart'; 24 import 'package:analyzer/src/generated/java_io.dart';
24 import 'package:analyzer/src/generated/sdk.dart'; 25 import 'package:analyzer/src/generated/sdk.dart';
25 import 'package:analyzer/src/generated/sdk_io.dart'; 26 import 'package:analyzer/src/generated/sdk_io.dart';
26 import 'package:analyzer/options.dart'; 27 import 'package:analyzer/options.dart';
27 import 'package:args/args.dart'; 28 import 'package:args/args.dart';
28 29
29 /** 30 /**
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 static const String INCREMENTAL_RESOLUTION_LOG = "incremental-resolution-log"; 87 static const String INCREMENTAL_RESOLUTION_LOG = "incremental-resolution-log";
87 88
88 /** 89 /**
89 * The name of the option used to enable validation of incremental resolution 90 * The name of the option used to enable validation of incremental resolution
90 * results. 91 * results.
91 */ 92 */
92 static const String INCREMENTAL_RESOLUTION_VALIDATION = 93 static const String INCREMENTAL_RESOLUTION_VALIDATION =
93 "incremental-resolution-validation"; 94 "incremental-resolution-validation";
94 95
95 /** 96 /**
97 * The name of the option used to cause instrumentation to also be written to
98 * a local file.
99 */
100 static const String INSTRUMENTATION_LOG_FILE = "instrumentation-log-file";
101
102 /**
96 * The name of the option used to enable instrumentation. 103 * The name of the option used to enable instrumentation.
97 */ 104 */
98 static const String ENABLE_INSTRUMENTATION_OPTION = "enable-instrumentation"; 105 static const String ENABLE_INSTRUMENTATION_OPTION = "enable-instrumentation";
99 106
100 /** 107 /**
101 * The name of the option used to print usage information. 108 * The name of the option used to print usage information.
102 */ 109 */
103 static const String HELP_OPTION = "help"; 110 static const String HELP_OPTION = "help";
104 111
105 /** 112 /**
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 238
232 DartSdk defaultSdk; 239 DartSdk defaultSdk;
233 if (results[SDK_OPTION] != null) { 240 if (results[SDK_OPTION] != null) {
234 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION])); 241 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION]));
235 } else { 242 } else {
236 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, 243 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk,
237 // which will make a guess. 244 // which will make a guess.
238 defaultSdk = DirectoryBasedDartSdk.defaultSdk; 245 defaultSdk = DirectoryBasedDartSdk.defaultSdk;
239 } 246 }
240 247
248 if (instrumentationServer != null) {
249 String filePath = results[INSTRUMENTATION_LOG_FILE];
250 if (filePath != null) {
251 instrumentationServer = new MulticastInstrumentationServer(
252 [instrumentationServer, new FileInstrumentationServer(filePath)]);
253 }
254 }
241 InstrumentationService service = 255 InstrumentationService service =
242 new InstrumentationService(instrumentationServer); 256 new InstrumentationService(instrumentationServer);
243 service.logVersion( 257 service.logVersion(
244 _readUuid(service), 258 _readUuid(service),
245 results[CLIENT_ID], 259 results[CLIENT_ID],
246 results[CLIENT_VERSION], 260 results[CLIENT_VERSION],
247 AnalysisServer.VERSION, 261 AnalysisServer.VERSION,
248 defaultSdk.sdkVersion); 262 defaultSdk.sdkVersion);
249 AnalysisEngine.instance.instrumentationService = service; 263 AnalysisEngine.instance.instrumentationService = service;
250 // 264 //
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 ZoneSpecification zoneSpecification = new ZoneSpecification( 318 ZoneSpecification zoneSpecification = new ZoneSpecification(
305 handleUncaughtError: errorFunction, 319 handleUncaughtError: errorFunction,
306 print: printFunction); 320 print: printFunction);
307 return runZoned(callback, zoneSpecification: zoneSpecification); 321 return runZoned(callback, zoneSpecification: zoneSpecification);
308 } 322 }
309 323
310 /** 324 /**
311 * Create and return the parser used to parse the command-line arguments. 325 * Create and return the parser used to parse the command-line arguments.
312 */ 326 */
313 CommandLineParser _createArgParser() { 327 CommandLineParser _createArgParser() {
314 CommandLineParser parser = new CommandLineParser(alwaysIgnoreUnrecognized: t rue); 328 CommandLineParser parser =
329 new CommandLineParser(alwaysIgnoreUnrecognized: true);
315 parser.addOption( 330 parser.addOption(
316 CLIENT_ID, 331 CLIENT_ID,
317 help: "an identifier used to identify the client"); 332 help: "an identifier used to identify the client");
318 parser.addOption(CLIENT_VERSION, help: "the version of the client"); 333 parser.addOption(CLIENT_VERSION, help: "the version of the client");
319 parser.addFlag( 334 parser.addFlag(
320 ENABLE_INCREMENTAL_RESOLUTION_API, 335 ENABLE_INCREMENTAL_RESOLUTION_API,
321 help: "enable using incremental resolution for API changes", 336 help: "enable using incremental resolution for API changes",
322 defaultsTo: false, 337 defaultsTo: false,
323 negatable: false); 338 negatable: false);
324 parser.addFlag( 339 parser.addFlag(
325 ENABLE_INSTRUMENTATION_OPTION, 340 ENABLE_INSTRUMENTATION_OPTION,
326 help: "enable sending instrumentation information to a server", 341 help: "enable sending instrumentation information to a server",
327 defaultsTo: false, 342 defaultsTo: false,
328 negatable: false); 343 negatable: false);
329 parser.addFlag( 344 parser.addFlag(
330 HELP_OPTION, 345 HELP_OPTION,
331 help: "print this help message without starting a server", 346 help: "print this help message without starting a server",
332 defaultsTo: false, 347 defaultsTo: false,
333 negatable: false); 348 negatable: false);
334 parser.addOption( 349 parser.addOption(
335 INCREMENTAL_RESOLUTION_LOG, 350 INCREMENTAL_RESOLUTION_LOG,
336 help: "the description of the incremental resolution log"); 351 help: "the description of the incremental resolution log");
337 parser.addFlag( 352 parser.addFlag(
338 INCREMENTAL_RESOLUTION_VALIDATION, 353 INCREMENTAL_RESOLUTION_VALIDATION,
339 help: "enable validation of incremental resolution results (slow)", 354 help: "enable validation of incremental resolution results (slow)",
340 defaultsTo: false, 355 defaultsTo: false,
341 negatable: false); 356 negatable: false);
357 parser.addOption(
358 INSTRUMENTATION_LOG_FILE,
359 help: "the path of the file to which instrumentation data will be writte n");
342 parser.addFlag( 360 parser.addFlag(
343 INTERNAL_PRINT_TO_CONSOLE, 361 INTERNAL_PRINT_TO_CONSOLE,
344 help: "enable sending `print` output to the console", 362 help: "enable sending `print` output to the console",
345 defaultsTo: false, 363 defaultsTo: false,
346 negatable: false); 364 negatable: false);
347 parser.addOption( 365 parser.addOption(
348 PORT_OPTION, 366 PORT_OPTION,
349 help: "[port] the port on which the server will listen"); 367 help: "[port] the port on which the server will listen");
350 parser.addOption(INTERNAL_DELAY_FREQUENCY); 368 parser.addOption(INTERNAL_DELAY_FREQUENCY);
351 parser.addOption(SDK_OPTION, help: "[path] the path to the sdk"); 369 parser.addOption(SDK_OPTION, help: "[path] the path to the sdk");
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 uuidFile.parent.createSync(recursive: true); 426 uuidFile.parent.createSync(recursive: true);
409 uuidFile.writeAsStringSync(uuid); 427 uuidFile.writeAsStringSync(uuid);
410 } catch (exception, stackTrace) { 428 } catch (exception, stackTrace) {
411 service.logPriorityException(exception, stackTrace); 429 service.logPriorityException(exception, stackTrace);
412 // Slightly alter the uuid to indicate it was not persisted 430 // Slightly alter the uuid to indicate it was not persisted
413 uuid = 'temp-$uuid'; 431 uuid = 'temp-$uuid';
414 } 432 }
415 return uuid; 433 return uuid;
416 } 434 }
417 } 435 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698