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

Unified Diff: pkg/barback/lib/src/transform_logger.dart

Issue 22396004: Make observable transform a barback transform. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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/barback/lib/src/transform.dart ('k') | pkg/barback/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/transform_logger.dart
diff --git a/pkg/barback/lib/src/transform_logger.dart b/pkg/barback/lib/src/transform_logger.dart
new file mode 100644
index 0000000000000000000000000000000000000000..131be29e8f54d14f39e71378a23c942378ebf443
--- /dev/null
+++ b/pkg/barback/lib/src/transform_logger.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library barback.transform_logger;
+
+import 'package:source_maps/span.dart';
+
+/// Object used to report warnings and errors encountered while running a
+/// transformer.
+class TransformLogger {
+
+ bool _shouldPrint;
+
+ TransformLogger(this._shouldPrint);
+
+ /// Logs a warning message.
+ ///
+ /// If present, [span] indicates the location in the input asset that caused
+ /// the warning.
+ void warning(String message, [Span span]) {
+ _printMessage('warning', message, span);
+ }
+
+ /// Logs an error message.
+ ///
+ /// If present, [span] indicates the location in the input asset that caused
+ /// the error.
+ // TODO(sigmund,nweiz): clarify when an error should be logged or thrown.
+ void error(String message, [Span span]) {
+ _printMessage('error', message, span);
+ }
+
+ // TODO(sigmund,rnystrom): do something better than printing.
+ _printMessage(String prefix, String message, Span span) {
+ if (!_shouldPrint) return;
+ print(span == null ? '$prefix $message'
+ : '$prefix ${span.getLocationMessage(message)}');
+ }
+}
« no previous file with comments | « pkg/barback/lib/src/transform.dart ('k') | pkg/barback/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698