| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /** | 5 /** |
| 6 * A representation of the contents of an instrumentation log. | 6 * A representation of the contents of an instrumentation log. |
| 7 */ | 7 */ |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:math' as math; | 9 import 'dart:math' as math; |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void _appendDetails(StringBuffer buffer) { | 155 void _appendDetails(StringBuffer buffer) { |
| 156 super._appendDetails(buffer); | 156 super._appendDetails(buffer); |
| 157 for (String component in components) { | 157 for (String component in components) { |
| 158 buffer.write(component); | 158 buffer.write(component); |
| 159 buffer.write('<br>'); | 159 buffer.write('<br>'); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 | 163 |
| 164 /** | 164 /** |
| 165 * A log entry representing an PluginErr entry. |
| 166 */ |
| 167 class GenericPluginEntry extends GenericEntry with PluginEntryMixin { |
| 168 /** |
| 169 * The components describing the plugin associated with this entry. |
| 170 */ |
| 171 final List<String> pluginData; |
| 172 |
| 173 /** |
| 174 * Initialize a newly created log entry. |
| 175 */ |
| 176 GenericPluginEntry(int index, int timeStamp, String entryKind, |
| 177 List<String> components, this.pluginData) |
| 178 : super(index, timeStamp, entryKind, components); |
| 179 } |
| 180 |
| 181 /** |
| 165 * A representation of an instrumentation log. | 182 * A representation of an instrumentation log. |
| 166 */ | 183 */ |
| 167 class InstrumentationLog { | 184 class InstrumentationLog { |
| 168 /** | 185 /** |
| 169 * The paths of the log files containing the entries. | 186 * The paths of the log files containing the entries. |
| 170 */ | 187 */ |
| 171 List<String> logFilePaths; | 188 List<String> logFilePaths; |
| 172 | 189 |
| 173 /** | 190 /** |
| 174 * The entries in the instrumentation log. | 191 * The entries in the instrumentation log. |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 _format(buffer, newIndent, element); | 561 _format(buffer, newIndent, element); |
| 545 buffer.write('<br>'); | 562 buffer.write('<br>'); |
| 546 }); | 563 }); |
| 547 buffer.write(indent); | 564 buffer.write(indent); |
| 548 buffer.write(']'); | 565 buffer.write(']'); |
| 549 } | 566 } |
| 550 } | 567 } |
| 551 } | 568 } |
| 552 | 569 |
| 553 /** | 570 /** |
| 571 * A log entry representing a communication between the server and a plugin. |
| 572 */ |
| 573 abstract class JsonBasedPluginEntry extends JsonBasedEntry |
| 574 with PluginEntryMixin { |
| 575 /** |
| 576 * The components describing the plugin associated with this entry. |
| 577 */ |
| 578 final List<String> pluginData; |
| 579 |
| 580 /** |
| 581 * Initialize a newly created entry to have the given [timeStamp] and |
| 582 * [notificationData] and to be associated with the plugin with the given |
| 583 * [pluginData]. |
| 584 */ |
| 585 JsonBasedPluginEntry( |
| 586 int index, int timeStamp, Map notificationData, this.pluginData) |
| 587 : super(index, timeStamp, notificationData); |
| 588 } |
| 589 |
| 590 /** |
| 554 * A single entry in an instrumentation log. | 591 * A single entry in an instrumentation log. |
| 555 */ | 592 */ |
| 556 abstract class LogEntry { | 593 abstract class LogEntry { |
| 557 /** | 594 /** |
| 558 * The character used to separate fields within an entry. | 595 * The character used to separate fields within an entry. |
| 559 */ | 596 */ |
| 560 static final int fieldSeparator = ':'.codeUnitAt(0); | 597 static final int fieldSeparator = ':'.codeUnitAt(0); |
| 561 | 598 |
| 562 /** | 599 /** |
| 563 * A regular expression that will match the beginning of a valid log entry. | 600 * A regular expression that will match the beginning of a valid log entry. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 } else if (entryKind == InstrumentationService.TAG_FILE_READ) { | 669 } else if (entryKind == InstrumentationService.TAG_FILE_READ) { |
| 633 // Fall through | 670 // Fall through |
| 634 } else if (entryKind == InstrumentationService.TAG_LOG_ENTRY) { | 671 } else if (entryKind == InstrumentationService.TAG_LOG_ENTRY) { |
| 635 // Fall through | 672 // Fall through |
| 636 } else if (entryKind == InstrumentationService.TAG_NOTIFICATION) { | 673 } else if (entryKind == InstrumentationService.TAG_NOTIFICATION) { |
| 637 Map requestData = JSON.decode(components[2]); | 674 Map requestData = JSON.decode(components[2]); |
| 638 return new NotificationEntry(index, timeStamp, requestData); | 675 return new NotificationEntry(index, timeStamp, requestData); |
| 639 } else if (entryKind == InstrumentationService.TAG_PERFORMANCE) { | 676 } else if (entryKind == InstrumentationService.TAG_PERFORMANCE) { |
| 640 // Fall through | 677 // Fall through |
| 641 } else if (entryKind == InstrumentationService.TAG_PLUGIN_ERROR) { | 678 } else if (entryKind == InstrumentationService.TAG_PLUGIN_ERROR) { |
| 642 return new PluginErrorEntry( | 679 return new PluginErrorEntry(index, timeStamp, entryKind, |
| 643 index, timeStamp, entryKind, components[2], components.sublist(3)); | 680 components.sublist(2, 4), components.sublist(4)); |
| 644 } else if (entryKind == InstrumentationService.TAG_PLUGIN_EXCEPTION) { | 681 } else if (entryKind == InstrumentationService.TAG_PLUGIN_EXCEPTION) { |
| 645 return new PluginExceptionEntry( | 682 return new PluginExceptionEntry(index, timeStamp, entryKind, |
| 646 index, timeStamp, entryKind, components[2], components.sublist(3)); | 683 components.sublist(2, 5), components.sublist(5)); |
| 647 } else if (entryKind == InstrumentationService.TAG_PLUGIN_NOTIFICATION) { | 684 } else if (entryKind == InstrumentationService.TAG_PLUGIN_NOTIFICATION) { |
| 648 Map requestData = JSON.decode(components[3]); | 685 Map requestData = JSON.decode(components[2]); |
| 649 return new PluginNotificationEntry( | 686 return new PluginNotificationEntry( |
| 650 index, timeStamp, components[2], requestData); | 687 index, timeStamp, requestData, components.sublist(3)); |
| 651 } else if (entryKind == InstrumentationService.TAG_PLUGIN_REQUEST) { | 688 } else if (entryKind == InstrumentationService.TAG_PLUGIN_REQUEST) { |
| 652 Map requestData = JSON.decode(components[3]); | 689 Map requestData = JSON.decode(components[2]); |
| 653 return new PluginRequestEntry( | 690 return new PluginRequestEntry( |
| 654 index, timeStamp, components[2], requestData); | 691 index, timeStamp, requestData, components.sublist(3)); |
| 655 } else if (entryKind == InstrumentationService.TAG_PLUGIN_RESPONSE) { | 692 } else if (entryKind == InstrumentationService.TAG_PLUGIN_RESPONSE) { |
| 656 Map responseData = JSON.decode(components[3]); | 693 Map responseData = JSON.decode(components[2]); |
| 657 return new PluginResponseEntry( | 694 return new PluginResponseEntry( |
| 658 index, timeStamp, components[2], responseData); | 695 index, timeStamp, responseData, components.sublist(3)); |
| 659 } else if (entryKind == InstrumentationService.TAG_PLUGIN_TIMEOUT) { | 696 } else if (entryKind == InstrumentationService.TAG_PLUGIN_TIMEOUT) { |
| 660 return new PluginErrorEntry( | 697 return new PluginErrorEntry(index, timeStamp, entryKind, |
| 661 index, timeStamp, entryKind, components[2], components.sublist(3)); | 698 components.sublist(2, 3), components.sublist(3)); |
| 662 } else if (entryKind == InstrumentationService.TAG_REQUEST) { | 699 } else if (entryKind == InstrumentationService.TAG_REQUEST) { |
| 663 Map requestData = JSON.decode(components[2]); | 700 Map requestData = JSON.decode(components[2]); |
| 664 return new RequestEntry(index, timeStamp, requestData); | 701 return new RequestEntry(index, timeStamp, requestData); |
| 665 } else if (entryKind == InstrumentationService.TAG_RESPONSE) { | 702 } else if (entryKind == InstrumentationService.TAG_RESPONSE) { |
| 666 Map responseData = JSON.decode(components[2]); | 703 Map responseData = JSON.decode(components[2]); |
| 667 return new ResponseEntry(index, timeStamp, responseData); | 704 return new ResponseEntry(index, timeStamp, responseData); |
| 668 } else if (entryKind == InstrumentationService.TAG_SUBPROCESS_START) { | 705 } else if (entryKind == InstrumentationService.TAG_SUBPROCESS_START) { |
| 669 // Fall through | 706 // Fall through |
| 670 } else if (entryKind == InstrumentationService.TAG_SUBPROCESS_RESULT) { | 707 } else if (entryKind == InstrumentationService.TAG_SUBPROCESS_RESULT) { |
| 671 // Fall through | 708 // Fall through |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 if (parameters is Map) { | 863 if (parameters is Map) { |
| 827 return parameters[parameterName]; | 864 return parameters[parameterName]; |
| 828 } | 865 } |
| 829 return null; | 866 return null; |
| 830 } | 867 } |
| 831 } | 868 } |
| 832 | 869 |
| 833 /** | 870 /** |
| 834 * A log entry representing a communication between the server and a plugin. | 871 * A log entry representing a communication between the server and a plugin. |
| 835 */ | 872 */ |
| 836 abstract class PluginEntry extends JsonBasedEntry with PluginEntryMixin { | |
| 837 /** | |
| 838 * The id of the plugin being communicated with. | |
| 839 */ | |
| 840 final String pluginId; | |
| 841 | |
| 842 /** | |
| 843 * Initialize a newly created entry to have the given [timeStamp] and | |
| 844 * [notificationData] and to be associated with the plugin with the given | |
| 845 * [pluginId]. | |
| 846 */ | |
| 847 PluginEntry(int index, int timeStamp, this.pluginId, Map notificationData) | |
| 848 : super(index, timeStamp, notificationData); | |
| 849 } | |
| 850 | |
| 851 /** | |
| 852 * A log entry representing a communication between the server and a plugin. | |
| 853 */ | |
| 854 abstract class PluginEntryMixin { | 873 abstract class PluginEntryMixin { |
| 855 /** | 874 /** |
| 856 * The id of the plugin being communicated with. | 875 * The components describing the plugin associated with this entry. |
| 857 */ | 876 */ |
| 858 String get pluginId; | 877 List<String> get pluginData; |
| 878 |
| 879 /** |
| 880 * The id of the plugin associated with this entry. |
| 881 */ |
| 882 String get pluginId => pluginData[0]; |
| 883 |
| 884 /** |
| 885 * The name of the plugin associated with this entry. |
| 886 */ |
| 887 String get pluginName => pluginData[1]; |
| 888 |
| 889 /** |
| 890 * The version of the plugin associated with this entry. |
| 891 */ |
| 892 String get pluginVersion => pluginData[2]; |
| 859 | 893 |
| 860 /** | 894 /** |
| 861 * Return a shortened version of the plugin id. | 895 * Return a shortened version of the plugin id. |
| 862 */ | 896 */ |
| 863 String get shortPluginId { | 897 String get shortPluginId { |
| 864 int index = pluginId.lastIndexOf(path.separator); | 898 int index = pluginId.lastIndexOf(path.separator); |
| 865 if (index > 0) { | 899 if (index > 0) { |
| 866 return pluginId.substring(index + 1); | 900 return pluginId.substring(index + 1); |
| 867 } | 901 } |
| 868 return pluginId; | 902 return pluginId; |
| 869 } | 903 } |
| 870 } | 904 } |
| 871 | 905 |
| 872 /** | 906 /** |
| 873 * A log entry representing an PluginErr entry. | 907 * A log entry representing an PluginErr entry. |
| 874 */ | 908 */ |
| 875 class PluginErrorEntry extends GenericEntry with PluginEntryMixin { | 909 class PluginErrorEntry extends GenericPluginEntry { |
| 876 /** | |
| 877 * The id of the plugin that generated the error. | |
| 878 */ | |
| 879 final String pluginId; | |
| 880 | |
| 881 /** | 910 /** |
| 882 * Initialize a newly created log entry. | 911 * Initialize a newly created log entry. |
| 883 */ | 912 */ |
| 884 PluginErrorEntry(int index, int timeStamp, String entryKind, this.pluginId, | 913 PluginErrorEntry(int index, int timeStamp, String entryKind, |
| 885 List<String> components) | 914 List<String> components, List<String> pluginData) |
| 886 : super(index, timeStamp, entryKind, components); | 915 : super(index, timeStamp, entryKind, components, pluginData); |
| 887 } | 916 } |
| 888 | 917 |
| 889 /** | 918 /** |
| 890 * A log entry representing an PluginEx entry. | 919 * A log entry representing an PluginEx entry. |
| 891 */ | 920 */ |
| 892 class PluginExceptionEntry extends GenericEntry with PluginEntryMixin { | 921 class PluginExceptionEntry extends GenericPluginEntry { |
| 893 /** | |
| 894 * The id of the plugin that generated the exception. | |
| 895 */ | |
| 896 final String pluginId; | |
| 897 | |
| 898 /** | 922 /** |
| 899 * Initialize a newly created log entry. | 923 * Initialize a newly created log entry. |
| 900 */ | 924 */ |
| 901 PluginExceptionEntry(int index, int timeStamp, String entryKind, | 925 PluginExceptionEntry(int index, int timeStamp, String entryKind, |
| 902 this.pluginId, List<String> components) | 926 List<String> components, List<String> pluginData) |
| 903 : super(index, timeStamp, entryKind, components); | 927 : super(index, timeStamp, entryKind, components, pluginData); |
| 904 } | 928 } |
| 905 | 929 |
| 906 /** | 930 /** |
| 907 * A log entry representing a notification that was sent from a plugin to the | 931 * A log entry representing a notification that was sent from a plugin to the |
| 908 * server. | 932 * server. |
| 909 */ | 933 */ |
| 910 class PluginNotificationEntry extends PluginEntry { | 934 class PluginNotificationEntry extends JsonBasedPluginEntry { |
| 911 /** | 935 /** |
| 912 * Initialize a newly created notification to have the given [timeStamp] and | 936 * Initialize a newly created notification to have the given [timeStamp] and |
| 913 * [notificationData]. | 937 * [notificationData]. |
| 914 */ | 938 */ |
| 915 PluginNotificationEntry( | 939 PluginNotificationEntry( |
| 916 int index, int timeStamp, String pluginId, Map notificationData) | 940 int index, int timeStamp, Map notificationData, List<String> pluginData) |
| 917 : super(index, timeStamp, pluginId, notificationData); | 941 : super(index, timeStamp, notificationData, pluginData); |
| 918 | 942 |
| 919 /** | 943 /** |
| 920 * Return the event field of the notification. | 944 * Return the event field of the notification. |
| 921 */ | 945 */ |
| 922 String get event => data['event']; | 946 String get event => data['event']; |
| 923 | 947 |
| 924 @override | 948 @override |
| 925 String get kind => 'PluginNoti'; | 949 String get kind => 'PluginNoti'; |
| 926 | 950 |
| 927 /** | 951 /** |
| 928 * Return the value of the parameter with the given [parameterName], or `null` | 952 * Return the value of the parameter with the given [parameterName], or `null` |
| 929 * if there is no such parameter. | 953 * if there is no such parameter. |
| 930 */ | 954 */ |
| 931 dynamic param(String parameterName) { | 955 dynamic param(String parameterName) { |
| 932 var parameters = data['params']; | 956 var parameters = data['params']; |
| 933 if (parameters is Map) { | 957 if (parameters is Map) { |
| 934 return parameters[parameterName]; | 958 return parameters[parameterName]; |
| 935 } | 959 } |
| 936 return null; | 960 return null; |
| 937 } | 961 } |
| 938 } | 962 } |
| 939 | 963 |
| 940 /** | 964 /** |
| 941 * A log entry representing a request that was sent from the server to a plugin. | 965 * A log entry representing a request that was sent from the server to a plugin. |
| 942 */ | 966 */ |
| 943 class PluginRequestEntry extends PluginEntry { | 967 class PluginRequestEntry extends JsonBasedPluginEntry { |
| 944 /** | 968 /** |
| 945 * Initialize a newly created response to have the given [timeStamp] and | 969 * Initialize a newly created response to have the given [timeStamp] and |
| 946 * [requestData]. | 970 * [requestData]. |
| 947 */ | 971 */ |
| 948 PluginRequestEntry(int index, int timeStamp, String pluginId, Map requestData) | 972 PluginRequestEntry( |
| 949 : super(index, timeStamp, pluginId, requestData); | 973 int index, int timeStamp, Map requestData, List<String> pluginData) |
| 974 : super(index, timeStamp, requestData, pluginData); |
| 950 | 975 |
| 951 /** | 976 /** |
| 952 * Return the id field of the request. | 977 * Return the id field of the request. |
| 953 */ | 978 */ |
| 954 String get id => data['id']; | 979 String get id => data['id']; |
| 955 | 980 |
| 956 @override | 981 @override |
| 957 String get kind => 'PluginReq'; | 982 String get kind => 'PluginReq'; |
| 958 | 983 |
| 959 /** | 984 /** |
| (...skipping 11 matching lines...) Expand all Loading... |
| 971 return parameters[parameterName]; | 996 return parameters[parameterName]; |
| 972 } | 997 } |
| 973 return null; | 998 return null; |
| 974 } | 999 } |
| 975 } | 1000 } |
| 976 | 1001 |
| 977 /** | 1002 /** |
| 978 * A log entry representing a response that was sent from a plugin to the | 1003 * A log entry representing a response that was sent from a plugin to the |
| 979 * server. | 1004 * server. |
| 980 */ | 1005 */ |
| 981 class PluginResponseEntry extends PluginEntry { | 1006 class PluginResponseEntry extends JsonBasedPluginEntry { |
| 982 /** | 1007 /** |
| 983 * Initialize a newly created response to have the given [timeStamp] and | 1008 * Initialize a newly created response to have the given [timeStamp] and |
| 984 * [responseData]. | 1009 * [responseData]. |
| 985 */ | 1010 */ |
| 986 PluginResponseEntry( | 1011 PluginResponseEntry( |
| 987 int index, int timeStamp, String pluginId, Map responseData) | 1012 int index, int timeStamp, Map responseData, List<String> pluginData) |
| 988 : super(index, timeStamp, pluginId, responseData); | 1013 : super(index, timeStamp, responseData, pluginData); |
| 989 | 1014 |
| 990 /** | 1015 /** |
| 991 * Return the id field of the response. | 1016 * Return the id field of the response. |
| 992 */ | 1017 */ |
| 993 String get id => data['id']; | 1018 String get id => data['id']; |
| 994 | 1019 |
| 995 @override | 1020 @override |
| 996 String get kind => 'PluginRes'; | 1021 String get kind => 'PluginRes'; |
| 997 | 1022 |
| 998 /** | 1023 /** |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 int slash = context.lastIndexOf('/'); | 1186 int slash = context.lastIndexOf('/'); |
| 1162 if (slash < 0) { | 1187 if (slash < 0) { |
| 1163 slash = context.lastIndexOf('\\'); | 1188 slash = context.lastIndexOf('\\'); |
| 1164 } | 1189 } |
| 1165 if (slash >= 0) { | 1190 if (slash >= 0) { |
| 1166 String prefix = context.substring(0, slash); | 1191 String prefix = context.substring(0, slash); |
| 1167 _target = _target.replaceAll(prefix, '...'); | 1192 _target = _target.replaceAll(prefix, '...'); |
| 1168 } | 1193 } |
| 1169 } | 1194 } |
| 1170 } | 1195 } |
| OLD | NEW |