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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library barback.transform_logger;
6
7 import 'package:source_maps/span.dart';
8
9 /// Object used to report warnings and errors encountered while running a
10 /// transformer.
11 class TransformLogger {
12
13 bool _shouldPrint;
14
15 TransformLogger(this._shouldPrint);
16
17 /// Logs a warning message.
18 ///
19 /// If present, [span] indicates the location in the input asset that caused
20 /// the warning.
21 void warning(String message, [Span span]) {
22 _printMessage('warning', message, span);
23 }
24
25 /// Logs an error message.
26 ///
27 /// If present, [span] indicates the location in the input asset that caused
28 /// the error.
29 // TODO(sigmund,nweiz): clarify when an error should be logged or thrown.
30 void error(String message, [Span span]) {
31 _printMessage('error', message, span);
32 }
33
34 // TODO(sigmund,rnystrom): do something better than printing.
35 _printMessage(String prefix, String message, Span span) {
36 if (!_shouldPrint) return;
37 print(span == null ? '$prefix $message'
38 : '$prefix ${span.getLocationMessage(message)}');
39 }
40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698