Chromium Code Reviews| Index: pkg/analyzer/lib/instrumentation/instrumentation.dart |
| diff --git a/pkg/analyzer/lib/instrumentation/instrumentation.dart b/pkg/analyzer/lib/instrumentation/instrumentation.dart |
| index ac01fef8ce1c542bad06286e29914a0e52da1444..979fc510ff46e25990aca4544b4c4eb6639de2bb 100644 |
| --- a/pkg/analyzer/lib/instrumentation/instrumentation.dart |
| +++ b/pkg/analyzer/lib/instrumentation/instrumentation.dart |
| @@ -75,9 +75,12 @@ class InstrumentationService { |
| static const String TAG_LOG_ENTRY = 'Log'; |
| static const String TAG_NOTIFICATION = 'Noti'; |
| static const String TAG_PERFORMANCE = 'Perf'; |
| + static const String TAG_PLUGIN_ERROR = 'PluginErr'; |
| + static const String TAG_PLUGIN_EXCEPTION = 'PluginEx'; |
| static const String TAG_PLUGIN_NOTIFICATION = 'PluginNoti'; |
| static const String TAG_PLUGIN_REQUEST = 'PluginReq'; |
| static const String TAG_PLUGIN_RESPONSE = 'PluginRes'; |
| + static const String TAG_PLUGIN_TIMEOUT = 'PluginTo'; |
| static const String TAG_REQUEST = 'Req'; |
| static const String TAG_RESPONSE = 'Res'; |
| static const String TAG_SUBPROCESS_START = 'SPStart'; |
| @@ -204,6 +207,37 @@ class InstrumentationService { |
| } |
| } |
| + /** |
| + * Log the fact that an error, described by the given [message], was reported |
| + * by the given [plugin]. |
| + */ |
| + void logPluginError( |
| + PluginData plugin, String code, String message, String stackTrace) { |
| + List<String> fields = <String>[TAG_PLUGIN_ERROR]; |
| + fields.add(code ?? ''); |
| + fields.add(message ?? ''); |
| + fields.add(stackTrace ?? ''); |
| + plugin.addToFields(fields); |
| + _instrumentationServer.log(_join(fields)); |
|
scheglov
2017/04/19 17:46:59
Why don't we check for null in this method?
Brian Wilkerson
2017/04/19 18:01:13
Done
|
| + } |
| + |
| + /** |
| + * Log that the given non-priority [exception] was thrown, with the given |
| + * [stackTrace] by the given [plugin]. |
| + */ |
| + void logPluginException( |
| + PluginData plugin, dynamic exception, StackTrace stackTrace) { |
| + if (_instrumentationServer != null) { |
| + List<String> fields = <String>[ |
| + TAG_PLUGIN_EXCEPTION, |
| + _toString(exception), |
| + _toString(stackTrace) |
| + ]; |
| + plugin.addToFields(fields); |
| + _instrumentationServer.log(_join(fields)); |
| + } |
| + } |
| + |
| void logPluginNotification(Uri pluginUri, String notification) { |
| if (_instrumentationServer != null) { |
| _instrumentationServer.log( |
| @@ -226,6 +260,17 @@ class InstrumentationService { |
| } |
| /** |
| + * Log that the given [plugin] took too long to execute the given [request]. |
| + */ |
| + void logPluginTimeout(PluginData plugin, String request) { |
| + if (_instrumentationServer != null) { |
| + List<String> fields = <String>[TAG_PLUGIN_TIMEOUT, request]; |
| + plugin.addToFields(fields); |
| + _instrumentationServer.log(_join(fields)); |
| + } |
| + } |
| + |
| + /** |
| * Log that the given priority [exception] was thrown, with the given |
| * [stackTrace]. |
| */ |
| @@ -428,3 +473,42 @@ class MulticastInstrumentationServer implements InstrumentationServer { |
| } |
| } |
| } |
| + |
| +/** |
| + * Information about a plugin. |
| + */ |
| +class PluginData { |
| + /** |
| + * The path to the plugin. |
| + */ |
| + final String path; |
| + |
| + /** |
| + * The name of the plugin. |
| + */ |
| + final String name; |
| + |
| + /** |
| + * The version of the plugin. |
| + */ |
| + final String version; |
| + |
| + /** |
| + * Initialize a newly created set of data about a plugin. |
| + */ |
| + PluginData(this.path, this.name, this.version); |
| + |
| + /** |
| + * Add the information about the plugin to the list of [fields] to be sent to |
| + * the instrumentation server. |
| + */ |
| + void addToFields(List<String> fields) { |
| + fields.add(path); |
| + if (name != null) { |
| + fields.add(name); |
| + } |
| + if (version != null) { |
| + fields.add(version); |
| + } |
| + } |
| +} |