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

Side by Side Diff: pkg/code_transformers/lib/messages/build_logger.dart

Issue 543963002: Link to stable-errors site from pub-build messages on the command line. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/polymer/lib/src/build/generated/messages.html » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library code_transformers.messages.messages_logger; 5 library code_transformers.messages.messages_logger;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert' show JSON; 8 import 'dart:convert' show JSON;
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 22 matching lines...) Expand all
33 /// Underling transform that is currently active. 33 /// Underling transform that is currently active.
34 final Transform _transform; 34 final Transform _transform;
35 35
36 /// Logs created during the current transform. 36 /// Logs created during the current transform.
37 final LogEntryTable _logs = new LogEntryTable(); 37 final LogEntryTable _logs = new LogEntryTable();
38 38
39 /// Whether to use `warning` or `error` when forwarding error messages to the 39 /// Whether to use `warning` or `error` when forwarding error messages to the
40 /// underlying logger in `_transform.logger`. 40 /// underlying logger in `_transform.logger`.
41 final bool convertErrorsToWarnings; 41 final bool convertErrorsToWarnings;
42 42
43 BuildLogger(this._transform, {this.convertErrorsToWarnings: false}); 43 /// Uri prefix to link for additional details. If set, messages logged through
44 /// this logger will contain an additional sentence, telling users to find
45 /// more details at `$detailsUri#packagename_id`.
46 final String detailsUri;
47
48 BuildLogger(this._transform, {this.convertErrorsToWarnings: false,
49 this.detailsUri: 'http://goo.gl/5HPeuP'});
jakemac 2014/09/05 22:19:29 Since this isn't part of the polymer package, we p
44 50
45 /// Records a message at the fine level. If [msg] is a [Message] it is 51 /// Records a message at the fine level. If [msg] is a [Message] it is
46 /// recorded directly, otherwise it is first converted to a [String]. 52 /// recorded directly, otherwise it is first converted to a [String].
47 void fine(msg, {AssetId asset, SourceSpan span}) { 53 void fine(msg, {AssetId asset, SourceSpan span}) {
48 msg = msg is Message ? msg : new Message.unknown('$msg'); 54 msg = msg is Message ? msg : new Message.unknown('$msg');
49 _transform.logger.fine(msg.snippet, asset: asset, span: span); 55 _transform.logger.fine(_snippet(msg), asset: asset, span: span);
50 _logs.add(new BuildLogEntry(msg, span, LogLevel.FINE.name)); 56 _logs.add(new BuildLogEntry(msg, span, LogLevel.FINE.name));
51 } 57 }
52 58
53 /// Records a message at the info level. If [msg] is a [Message] it is 59 /// Records a message at the info level. If [msg] is a [Message] it is
54 /// recorded directly, otherwise it is first converted to a [String]. 60 /// recorded directly, otherwise it is first converted to a [String].
55 void info(msg, {AssetId asset, SourceSpan span}) { 61 void info(msg, {AssetId asset, SourceSpan span}) {
56 msg = msg is Message ? msg : new Message.unknown('$msg'); 62 msg = msg is Message ? msg : new Message.unknown('$msg');
57 _transform.logger.info(msg.snippet, asset: asset, span: span); 63 _transform.logger.info(_snippet(msg), asset: asset, span: span);
58 _logs.add(new BuildLogEntry(msg, span, LogLevel.INFO.name)); 64 _logs.add(new BuildLogEntry(msg, span, LogLevel.INFO.name));
59 } 65 }
60 66
61 /// Records a warning message. If [msg] is a [Message] it is recorded 67 /// Records a warning message. If [msg] is a [Message] it is recorded
62 /// directly, otherwise it is first converted to a [String]. 68 /// directly, otherwise it is first converted to a [String].
63 void warning(msg, {AssetId asset, SourceSpan span}) { 69 void warning(msg, {AssetId asset, SourceSpan span}) {
64 msg = msg is Message ? msg : new Message.unknown('$msg'); 70 msg = msg is Message ? msg : new Message.unknown('$msg');
65 _transform.logger.warning(msg.snippet, asset: asset, span: span); 71 _transform.logger.warning(_snippet(msg), asset: asset, span: span);
66 _logs.add(new BuildLogEntry(msg, span, LogLevel.WARNING.name)); 72 _logs.add(new BuildLogEntry(msg, span, LogLevel.WARNING.name));
67 } 73 }
68 74
69 /// Records an error message. If [msg] is a [Message] it is recorded 75 /// Records an error message. If [msg] is a [Message] it is recorded
70 /// directly, otherwise it is first converted to a [String]. 76 /// directly, otherwise it is first converted to a [String].
71 void error(msg, {AssetId asset, SourceSpan span}) { 77 void error(msg, {AssetId asset, SourceSpan span}) {
72 msg = msg is Message ? msg : new Message.unknown('$msg'); 78 msg = msg is Message ? msg : new Message.unknown('$msg');
73 if (convertErrorsToWarnings) { 79 if (convertErrorsToWarnings) {
74 _transform.logger.warning(msg.snippet, asset: asset, span: span); 80 _transform.logger.warning(_snippet(msg), asset: asset, span: span);
75 } else { 81 } else {
76 _transform.logger.error(msg.snippet, asset: asset, span: span); 82 _transform.logger.error(_snippet(msg), asset: asset, span: span);
77 } 83 }
78 _logs.add(new BuildLogEntry(msg, span, LogLevel.ERROR.name)); 84 _logs.add(new BuildLogEntry(msg, span, LogLevel.ERROR.name));
79 } 85 }
80 86
87 String _snippet(Message msg) {
88 var s = msg.snippet;
89 if (detailsUri == null) return s;
90 var dot = s.endsWith('.') ? '' : '.';
91 var hashTag = '${msg.id.package}_${msg.id.id}';
92 return '$s$dot See $detailsUri#$hashTag for details.';
93 }
94
81 /// Outputs the log data to a JSON serialized file. 95 /// Outputs the log data to a JSON serialized file.
82 Future writeOutput() { 96 Future writeOutput() {
83 return _getNextLogAssetPath().then((path) { 97 return _getNextLogAssetPath().then((path) {
84 _transform.addOutput(new Asset.fromString(path, 98 _transform.addOutput(new Asset.fromString(path,
85 JSON.encode(_logs))); 99 JSON.encode(_logs)));
86 }); 100 });
87 } 101 }
88 102
89 // Each phase outputs a new log file with an incrementing # appended, this 103 // Each phase outputs a new log file with an incrementing # appended, this
90 // figures out the next # to use. 104 // figures out the next # to use.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 136 }
123 137
124 // Reads all logs for an asset and adds them to this loggers log output. 138 // Reads all logs for an asset and adds them to this loggers log output.
125 Future addLogFilesFromAsset(AssetId id, [int nextNumber = 1]) { 139 Future addLogFilesFromAsset(AssetId id, [int nextNumber = 1]) {
126 return _readLogFilesForAsset(id, _transform, _logs); 140 return _readLogFilesForAsset(id, _transform, _logs);
127 } 141 }
128 } 142 }
129 143
130 /// Extension used for assets that contained serialized logs. 144 /// Extension used for assets that contained serialized logs.
131 const String LOG_EXTENSION = '._buildLogs'; 145 const String LOG_EXTENSION = '._buildLogs';
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer/lib/src/build/generated/messages.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698