| 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 import 'dart:math' as math; | 5 import 'dart:math' as math; |
| 6 | 6 |
| 7 import '../log/log.dart'; | 7 import '../log/log.dart'; |
| 8 import '../server.dart'; | 8 import '../server.dart'; |
| 9 import 'page_writer.dart'; | 9 import 'page_writer.dart'; |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 * be written. | 38 * be written. |
| 39 */ | 39 */ |
| 40 int pageLength = null; | 40 int pageLength = null; |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * The number of digits in the event stamps that are the same for every entry. | 43 * The number of digits in the event stamps that are the same for every entry. |
| 44 */ | 44 */ |
| 45 int prefixLength; | 45 int prefixLength; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * A table mapping the ids of plugins to an index for the plugin. |
| 49 */ |
| 50 Map<String, int> pluginIdMap = <String, int>{}; |
| 51 |
| 52 /** |
| 48 * Initialize a newly created writer to write the content of the given | 53 * Initialize a newly created writer to write the content of the given |
| 49 * [instrumentationLog]. | 54 * [instrumentationLog]. |
| 50 */ | 55 */ |
| 51 LogPage(this.log); | 56 LogPage(this.log); |
| 52 | 57 |
| 58 /** |
| 59 * Return the encoding for the given [pluginId] that is used to build anchors. |
| 60 */ |
| 61 int getPluginId(String pluginId) { |
| 62 return pluginIdMap.putIfAbsent(pluginId, () => pluginIdMap.length); |
| 63 } |
| 64 |
| 53 @override | 65 @override |
| 54 void writeBody(StringSink sink) { | 66 void writeBody(StringSink sink) { |
| 55 entries = log.entriesInGroup(selectedGroup); | 67 entries = log.entriesInGroup(selectedGroup); |
| 56 prefixLength = computePrefixLength(entries); | 68 prefixLength = computePrefixLength(entries); |
| 57 | 69 |
| 58 writeMenu(sink); | 70 writeMenu(sink); |
| 59 writeTwoColumns( | 71 writeTwoColumns( |
| 60 sink, 'leftColumn', _writeLeftColumn, 'rightColumn', _writeRightColumn); | 72 sink, 'leftColumn', _writeLeftColumn, 'rightColumn', _writeRightColumn); |
| 61 } | 73 } |
| 62 | 74 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 if (pubStatus is Map) { | 178 if (pubStatus is Map) { |
| 167 if (pubStatus['isListingPackageDirs']) { | 179 if (pubStatus['isListingPackageDirs']) { |
| 168 description = '$description <span class="gray">(pub)</span>'; | 180 description = '$description <span class="gray">(pub)</span>'; |
| 169 } else { | 181 } else { |
| 170 String duration = _getDuration(pairedEntry, entry); | 182 String duration = _getDuration(pairedEntry, entry); |
| 171 description = | 183 description = |
| 172 '$description <span class="gray">(pub - $duration ms)</span>'; | 184 '$description <span class="gray">(pub - $duration ms)</span>'; |
| 173 } | 185 } |
| 174 } | 186 } |
| 175 } | 187 } |
| 188 } else if (entry is PluginRequestEntry) { |
| 189 String entryId = entry.id; |
| 190 int pluginId = getPluginId(entry.pluginId); |
| 191 id = 'req$pluginId.$entryId'; |
| 192 clickHandler = |
| 193 'highlight(\'req$pluginId.$entryId\', \'res$pluginId.$entryId\')'; |
| 194 icon = '→'; |
| 195 description = '${entry.method} (${entry.shortPluginId})'; |
| 196 } else if (entry is PluginResponseEntry) { |
| 197 String entryId = entry.id; |
| 198 int pluginId = getPluginId(entry.pluginId); |
| 199 PluginRequestEntry request = log.pluginRequestFor(entry); |
| 200 id = 'res$pluginId.$entryId'; |
| 201 clickHandler = |
| 202 'highlight(\'req$pluginId.$entryId\', \'res$pluginId.$entryId\')'; |
| 203 icon = '←'; |
| 204 if (request != null) { |
| 205 int latency = entry.timeStamp - request.timeStamp; |
| 206 description = |
| 207 '${request.method} <span class="gray">($latency ms)</span> (${entry.
shortPluginId})'; |
| 208 } |
| 209 } else if (entry is PluginNotificationEntry) { |
| 210 id = 'e${entry.index}'; |
| 211 LogEntry pairedEntry = log.pairedEntry(entry); |
| 212 if (pairedEntry != null) { |
| 213 String pairedId = 'e${pairedEntry.index}'; |
| 214 clickHandler = 'highlight(\'$id\', \'$pairedId\')'; |
| 215 } |
| 216 icon = '←'; |
| 217 description = '${entry.event} (${entry.shortPluginId})'; |
| 176 } else if (entry is TaskEntry) { | 218 } else if (entry is TaskEntry) { |
| 177 description = entry.description; | 219 description = entry.description; |
| 178 } else if (entry is ErrorEntry) { | 220 } else if (entry is ErrorEntry) { |
| 179 description = '<span class="error">$description</span>'; | 221 description = '<span class="error">$description</span>'; |
| 222 } else if (entry is PluginErrorEntry) { |
| 223 description = |
| 224 '<span class="error">$description</span> (${entry.shortPluginId})'; |
| 180 } else if (entry is ExceptionEntry) { | 225 } else if (entry is ExceptionEntry) { |
| 181 description = '<span class="error">$description</span>'; | 226 description = '<span class="error">$description</span>'; |
| 182 } else if (entry is MalformedLogEntry) { | 227 } else if (entry is MalformedLogEntry) { |
| 183 description = '<span class="error">$description</span>'; | 228 description = '<span class="error">$description</span>'; |
| 184 } | 229 } |
| 185 id = id == null ? '' : 'id="$id" '; | 230 id = id == null ? '' : 'id="$id" '; |
| 186 clickHandler = '$clickHandler; setDetails(\'${escape(entry.details())}\')'; | 231 clickHandler = '$clickHandler; setDetails(\'${escape(entry.details())}\')'; |
| 187 String timeStamp = entry.timeStamp.toString(); | 232 String timeStamp = entry.timeStamp.toString(); |
| 188 if (prefixLength > 0) { | 233 if (prefixLength > 0) { |
| 189 timeStamp = timeStamp.substring(prefixLength); | 234 timeStamp = timeStamp.substring(prefixLength); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 void _writeRightColumn(StringSink sink) { | 322 void _writeRightColumn(StringSink sink) { |
| 278 // | 323 // |
| 279 // Write the header of the column. | 324 // Write the header of the column. |
| 280 // | 325 // |
| 281 sink.writeln('<div class="columnHeader">'); | 326 sink.writeln('<div class="columnHeader">'); |
| 282 sink.writeln('<p><b>Entry Details</b></p>'); | 327 sink.writeln('<p><b>Entry Details</b></p>'); |
| 283 sink.writeln('</div>'); | 328 sink.writeln('</div>'); |
| 284 sink.writeln('<div id="details"></div>'); | 329 sink.writeln('<div id="details"></div>'); |
| 285 } | 330 } |
| 286 } | 331 } |
| OLD | NEW |