| 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 import 'asset_id.dart'; | 9 import 'asset_id.dart'; |
| 10 import 'log.dart'; | 10 import 'log.dart'; |
| 11 import 'transform.dart'; | 11 |
| 12 typedef void LogFunction(AssetId asset, LogLevel level, String message, |
| 13 Span span); |
| 12 | 14 |
| 13 /// Object used to report warnings and errors encountered while running a | 15 /// Object used to report warnings and errors encountered while running a |
| 14 /// transformer. | 16 /// transformer. |
| 15 class TransformLogger { | 17 class TransformLogger { |
| 16 final LogFunction _logFunction; | 18 final LogFunction _logFunction; |
| 17 | 19 |
| 18 TransformLogger(this._logFunction); | 20 TransformLogger(this._logFunction); |
| 19 | 21 |
| 20 /// Logs an informative message. | 22 /// Logs an informative message. |
| 21 /// | 23 /// |
| (...skipping 19 matching lines...) Expand all Loading... |
| 41 /// | 43 /// |
| 42 /// If [asset] is provided, the log entry is associated with that asset. | 44 /// If [asset] is provided, the log entry is associated with that asset. |
| 43 /// Otherwise it's associated with the primary input of [transformer]. | 45 /// Otherwise it's associated with the primary input of [transformer]. |
| 44 /// If present, [span] indicates the location in the input asset that caused | 46 /// If present, [span] indicates the location in the input asset that caused |
| 45 /// the error. | 47 /// the error. |
| 46 // TODO(sigmund,nweiz): clarify when an error should be logged or thrown. | 48 // TODO(sigmund,nweiz): clarify when an error should be logged or thrown. |
| 47 void error(String message, {AssetId asset, Span span}) { | 49 void error(String message, {AssetId asset, Span span}) { |
| 48 _logFunction(asset, LogLevel.ERROR, message, span); | 50 _logFunction(asset, LogLevel.ERROR, message, span); |
| 49 } | 51 } |
| 50 } | 52 } |
| OLD | NEW |