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

Side by Side Diff: pkg/analysis_server/tool/instrumentation/log/log.dart

Issue 2466403002: Fix bugs in the log viewer (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | pkg/analysis_server/tool/instrumentation/page/log_page.dart » ('j') | 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) 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 library analysis_server.tool.instrumentation.log.log; 8 library analysis_server.tool.instrumentation.log.log;
9 9
10 import 'dart:convert'; 10 import 'dart:convert';
11 import 'dart:math' as math;
11 12
12 import 'package:analyzer/instrumentation/instrumentation.dart'; 13 import 'package:analyzer/instrumentation/instrumentation.dart';
13 14
14 /** 15 /**
15 * A boolean-valued function of one argument. 16 * A boolean-valued function of one argument.
16 */ 17 */
17 typedef bool Predicate<T>(T value); 18 typedef bool Predicate<T>(T value);
18 19
19 /** 20 /**
20 * A description of a group of log entries. 21 * A description of a group of log entries.
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 return buffer.toString(); 298 return buffer.toString();
298 } 299 }
299 300
300 List<String> extraLines = <String>[]; 301 List<String> extraLines = <String>[];
301 for (int i = logContent.length - 1; i >= 0; i--) { 302 for (int i = logContent.length - 1; i >= 0; i--) {
302 String line = logContent[i]; 303 String line = logContent[i];
303 if (isStartOfEntry(line)) { 304 if (isStartOfEntry(line)) {
304 if (extraLines.isNotEmpty) { 305 if (extraLines.isNotEmpty) {
305 logContent[i] = merge(line, extraLines); 306 logContent[i] = merge(line, extraLines);
306 } 307 }
308 extraLines.clear();
307 } else { 309 } else {
308 logContent.removeAt(i); 310 logContent.removeAt(i);
309 extraLines.insert(0, line); 311 extraLines.insert(0, line);
310 } 312 }
311 } 313 }
312 if (extraLines.isNotEmpty) { 314 if (extraLines.isNotEmpty) {
313 throw new StateError( 315 int count = math.min(extraLines.length, 10);
314 '${extraLines.length} non-entry lines before any entry'); 316 StringBuffer buffer = new StringBuffer();
317 buffer.writeln('${extraLines.length} non-entry lines before any entry');
318 buffer.writeln('First $count lines:');
319 for (int i = 0; i < count; i++) {
320 buffer.writeln(extraLines[i]);
321 }
322 throw new StateError(buffer.toString());
315 } 323 }
316 } 324 }
317 325
318 /** 326 /**
319 * Parse the given [logContent] into a list of log entries. 327 * Parse the given [logContent] into a list of log entries.
320 */ 328 */
321 void _parseLogContent(List<String> logContent) { 329 void _parseLogContent(List<String> logContent) {
322 if (_isSessionData(logContent)) { 330 if (_isSessionData(logContent)) {
323 if (logContent[0].startsWith('-----')) { 331 if (logContent[0].startsWith('-----')) {
324 logContent.removeAt(0); 332 logContent.removeAt(0);
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 int slash = context.lastIndexOf('/'); 930 int slash = context.lastIndexOf('/');
923 if (slash < 0) { 931 if (slash < 0) {
924 slash = context.lastIndexOf('\\'); 932 slash = context.lastIndexOf('\\');
925 } 933 }
926 if (slash >= 0) { 934 if (slash >= 0) {
927 String prefix = context.substring(0, slash); 935 String prefix = context.substring(0, slash);
928 _target = _target.replaceAll(prefix, '...'); 936 _target = _target.replaceAll(prefix, '...');
929 } 937 }
930 } 938 }
931 } 939 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/tool/instrumentation/page/log_page.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698