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

Unified Diff: pkg/polymer/lib/src/build/log_injector.dart

Issue 513023002: Step one towards stable error messages with details: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/lib/src/build/log_injector.css ('k') | pkg/polymer/lib/src/build/messages.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/build/log_injector.dart
diff --git a/pkg/polymer/lib/src/build/log_injector.dart b/pkg/polymer/lib/src/build/log_injector.dart
index ba56b22121e319192f10e882211619b10a3e2a13..d90edc8e961e098980a981a961319ffc0690d725 100644
--- a/pkg/polymer/lib/src/build/log_injector.dart
+++ b/pkg/polymer/lib/src/build/log_injector.dart
@@ -12,6 +12,8 @@ import 'dart:convert';
import 'dart:html';
import 'package:path/path.dart' as path;
+import 'package:source_span/source_span.dart';
+import 'package:code_transformers/messages/messages.dart';
class LogInjector {
Element selectedMenu;
@@ -27,13 +29,16 @@ class LogInjector {
// multiple scripts running independently so we could ensure that this would
// always be running.
injectLogs(String data) {
+ var logs = new LogEntryTable.fromJson(JSON.decode(data));
+ if (logs.entries.isEmpty) return;
+
// Group all logs by level.
var logsByLevel = {
};
- JSON.decode(data).forEach((log) {
- logsByLevel.putIfAbsent(log['level'], () => []);
- logsByLevel[log['level']].add(log);
- });
+ logs.entries.values.forEach((list) => list.forEach((log) {
+ logsByLevel.putIfAbsent(log.level, () => []);
+ logsByLevel[log.level].add(log);
+ }));
if (logsByLevel.isEmpty) return;
// Build the wrapper, menu, and content divs.
@@ -84,25 +89,23 @@ class LogInjector {
for (var log in logs) {
var logHtml = new StringBuffer();
logHtml.write('<div class="log">');
- var message = log['message'].replaceAllMapped(_urlRegex,
+
+ var id = log.message.id;
+ var hashTag = 'msg_${id.package}_${id.id}';
+ var message = new HtmlEscape().convert(log.message.snippet);
+ message.replaceAllMapped(_urlRegex,
(m) => '<a href="${m.group(0)}" target="blank">${m.group(0)}</a>');
- logHtml.write('<div class="message $levelClassName">$message</div>');
- var assetId = log['assetId'];
- var span = log['span'];
- bool hasLocation = assetId != null || span != null;
- if (hasLocation) logHtml.write('<div class="location">');
- if (assetId != null) {
- logHtml.write(
- ' <span class="package">${assetId['package']}</span>:');
- if (span == null) {
- logHtml.write(' <span class="location">${assetId['path']}</span>');
- }
- }
+ logHtml.write('<div class="message $levelClassName">$message '
+ '<a target="blank" href='
+ '"/packages/polymer/src/build/generated/messages.html#$hashTag">'
+ '(more details)</a></div>');
+ var span = log.span;
if (span != null) {
+ logHtml.write('<div class="location">');
+ var text = new HtmlEscape().convert(span.text);
logHtml.write(
- ' <span class="location">${span['location']}</span></div>'
- ' <span class="text">${span['text']}</span>''</div>');
- } else if (hasLocation) {
+ ' <span class="location">${span.start.toolString}</span></div>'
+ ' <span class="text">$text</span>''</div>');
logHtml.write('</div>');
}
logHtml.write('</div>');
« no previous file with comments | « pkg/polymer/lib/src/build/log_injector.css ('k') | pkg/polymer/lib/src/build/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698