| OLD | NEW |
| 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 barback.transform_logger; | 5 library barback.transform_logger; |
| 6 | 6 |
| 7 import 'package:source_maps/span.dart'; | 7 import 'package:source_maps/span.dart'; |
| 8 | 8 |
| 9 /// Object used to report warnings and errors encountered while running a | 9 /// Object used to report warnings and errors encountered while running a |
| 10 /// transformer. | 10 /// transformer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 /// If present, [span] indicates the location in the input asset that caused | 35 /// If present, [span] indicates the location in the input asset that caused |
| 36 /// the error. | 36 /// the error. |
| 37 // TODO(sigmund,nweiz): clarify when an error should be logged or thrown. | 37 // TODO(sigmund,nweiz): clarify when an error should be logged or thrown. |
| 38 void error(String message, [Span span]) { | 38 void error(String message, [Span span]) { |
| 39 _printMessage('error', message, span); | 39 _printMessage('error', message, span); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // TODO(sigmund,rnystrom): do something better than printing. | 42 // TODO(sigmund,rnystrom): do something better than printing. |
| 43 _printMessage(String prefix, String message, Span span) { | 43 _printMessage(String prefix, String message, Span span) { |
| 44 if (!_shouldPrint) return; | 44 if (!_shouldPrint) return; |
| 45 print(span == null ? '$prefix $message' | 45 print(span == null ? '$prefix: $message' |
| 46 : '$prefix ${span.getLocationMessage(message)}'); | 46 : '$prefix ${span.getLocationMessage(message)}'); |
| 47 } | 47 } |
| 48 } | 48 } |
| OLD | NEW |