| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 messages; | 5 library messages; |
| 6 | 6 |
| 7 import 'package:html5lib/dom_parsing.dart'; | 7 import 'package:html5lib/dom_parsing.dart' show SourceSpan; |
| 8 import 'package:logging/logging.dart'; | 8 import 'package:logging/logging.dart' show Level; |
| 9 | 9 |
| 10 import 'file_system/path.dart'; | 10 import 'file_system/path.dart'; |
| 11 import 'options.dart'; | 11 import 'options.dart'; |
| 12 import 'utils.dart'; | 12 import 'utils.dart'; |
| 13 | 13 |
| 14 // TODO(jmesserly): remove the global messages. We instead use some | 14 // TODO(jmesserly): remove the global messages. We instead use some |
| 15 // object that tracks compilation state. | 15 // object that tracks compilation state. |
| 16 | 16 |
| 17 /** The global [Messages] for tracking info/warnings/messages. */ | 17 /** The global [Messages] for tracking info/warnings/messages. */ |
| 18 Messages messages; | 18 Messages messages; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 final SourceSpan span; | 35 final SourceSpan span; |
| 36 final bool useColors; | 36 final bool useColors; |
| 37 | 37 |
| 38 Message(this.level, this.message, {this.file, this.span, | 38 Message(this.level, this.message, {this.file, this.span, |
| 39 this.useColors: false}); | 39 this.useColors: false}); |
| 40 | 40 |
| 41 String toString() { | 41 String toString() { |
| 42 var output = new StringBuffer(); | 42 var output = new StringBuffer(); |
| 43 bool colors = useColors && _ERROR_COLORS.containsKey(level); | 43 bool colors = useColors && _ERROR_COLORS.containsKey(level); |
| 44 if (colors) output.add(_ERROR_COLORS[level]); | 44 if (colors) output.add(_ERROR_COLORS[level]); |
| 45 output.add(level.name); | 45 output.add(level.name).add(' '); |
| 46 if (colors) output.add(NO_COLOR); | 46 if (colors) output.add(NO_COLOR); |
| 47 | 47 |
| 48 if (span == null) { | 48 if (span == null) { |
| 49 if (file != null) output.add('$file: '); | 49 if (file != null) output.add('$file: '); |
| 50 output.add(message); | 50 output.add(message); |
| 51 } else { | 51 } else { |
| 52 output.add(span.toMessageString( | 52 output.add(span.toMessageString( |
| 53 file.toString(), message, useColors: colors)); | 53 file.toString(), message, useColors: colors)); |
| 54 } | 54 } |
| 55 | 55 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 */ | 102 */ |
| 103 void info(String message, SourceSpan span, {Path file}) { | 103 void info(String message, SourceSpan span, {Path file}) { |
| 104 var msg = new Message(Level.INFO, message, file: file, span: span, | 104 var msg = new Message(Level.INFO, message, file: file, span: span, |
| 105 useColors: options.useColors); | 105 useColors: options.useColors); |
| 106 | 106 |
| 107 messages.add(msg); | 107 messages.add(msg); |
| 108 | 108 |
| 109 if (options.verbose) printHandler(msg); | 109 if (options.verbose) printHandler(msg); |
| 110 } | 110 } |
| 111 } | 111 } |
| OLD | NEW |