| OLD | NEW |
| 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 analyzer.instrumentation.instrumentation; | 5 library analyzer.instrumentation.instrumentation; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:analyzer/task/model.dart'; | 10 import 'package:analyzer/task/model.dart'; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * The interface used by client code to communicate with an instrumentation | 21 * The interface used by client code to communicate with an instrumentation |
| 22 * server. | 22 * server. |
| 23 */ | 23 */ |
| 24 abstract class InstrumentationServer { | 24 abstract class InstrumentationServer { |
| 25 /** | 25 /** |
| 26 * Return the identifier used to identify the current session. | 26 * Return the identifier used to identify the current session. |
| 27 */ | 27 */ |
| 28 String get sessionId; | 28 String get sessionId; |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * A user-friendly description of this instrumentation server. |
| 32 */ |
| 33 String get describe; |
| 34 |
| 35 /** |
| 31 * Pass the given [message] to the instrumentation server so that it will be | 36 * Pass the given [message] to the instrumentation server so that it will be |
| 32 * logged with other messages. | 37 * logged with other messages. |
| 33 * | 38 * |
| 34 * This method should be used for most logging. | 39 * This method should be used for most logging. |
| 35 */ | 40 */ |
| 36 void log(String message); | 41 void log(String message); |
| 37 | 42 |
| 38 /** | 43 /** |
| 39 * Pass the given [message] to the instrumentation server so that it will be | 44 * Pass the given [message] to the instrumentation server so that it will be |
| 40 * logged with other messages. | 45 * logged with other messages. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 /** | 108 /** |
| 104 * Return the identifier used to identify the current session. | 109 * Return the identifier used to identify the current session. |
| 105 */ | 110 */ |
| 106 String get sessionId => _instrumentationServer?.sessionId ?? ''; | 111 String get sessionId => _instrumentationServer?.sessionId ?? ''; |
| 107 | 112 |
| 108 /** | 113 /** |
| 109 * The current time, expressed as a decimal encoded number of milliseconds. | 114 * The current time, expressed as a decimal encoded number of milliseconds. |
| 110 */ | 115 */ |
| 111 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString(); | 116 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString(); |
| 112 | 117 |
| 118 InstrumentationServer get instrumentationServer => _instrumentationServer; |
| 119 |
| 113 /** | 120 /** |
| 114 * Log that the given analysis [task] is being performed in the given | 121 * Log that the given analysis [task] is being performed in the given |
| 115 * [context]. | 122 * [context]. |
| 116 */ | 123 */ |
| 117 void logAnalysisTask(String context, AnalysisTask task) { | 124 void logAnalysisTask(String context, AnalysisTask task) { |
| 118 if (_instrumentationServer != null) { | 125 if (_instrumentationServer != null) { |
| 119 _instrumentationServer | 126 _instrumentationServer |
| 120 .log(_join([TAG_ANALYSIS_TASK, context, task.description])); | 127 .log(_join([TAG_ANALYSIS_TASK, context, task.description])); |
| 121 } | 128 } |
| 122 } | 129 } |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 */ | 370 */ |
| 364 class MulticastInstrumentationServer implements InstrumentationServer { | 371 class MulticastInstrumentationServer implements InstrumentationServer { |
| 365 final List<InstrumentationServer> _servers; | 372 final List<InstrumentationServer> _servers; |
| 366 | 373 |
| 367 MulticastInstrumentationServer(this._servers); | 374 MulticastInstrumentationServer(this._servers); |
| 368 | 375 |
| 369 @override | 376 @override |
| 370 String get sessionId => _servers[0].sessionId; | 377 String get sessionId => _servers[0].sessionId; |
| 371 | 378 |
| 372 @override | 379 @override |
| 380 String get describe { |
| 381 return _servers |
| 382 .map((InstrumentationServer server) => server.describe) |
| 383 .join("\n"); |
| 384 } |
| 385 |
| 386 @override |
| 373 void log(String message) { | 387 void log(String message) { |
| 374 for (InstrumentationServer server in _servers) { | 388 for (InstrumentationServer server in _servers) { |
| 375 server.log(message); | 389 server.log(message); |
| 376 } | 390 } |
| 377 } | 391 } |
| 378 | 392 |
| 379 @override | 393 @override |
| 380 void logWithPriority(String message) { | 394 void logWithPriority(String message) { |
| 381 for (InstrumentationServer server in _servers) { | 395 for (InstrumentationServer server in _servers) { |
| 382 server.logWithPriority(message); | 396 server.logWithPriority(message); |
| 383 } | 397 } |
| 384 } | 398 } |
| 385 | 399 |
| 386 @override | 400 @override |
| 387 Future shutdown() async { | 401 Future shutdown() async { |
| 388 for (InstrumentationServer server in _servers) { | 402 for (InstrumentationServer server in _servers) { |
| 389 await server.shutdown(); | 403 await server.shutdown(); |
| 390 } | 404 } |
| 391 } | 405 } |
| 392 } | 406 } |
| OLD | NEW |