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

Side by Side Diff: pkg/barback/lib/src/transformer/transform_logger.dart

Issue 808713003: Remove barback from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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.transformer.transform_logger;
6
7 import 'package:source_span/source_span.dart';
8
9 import '../asset/asset_id.dart';
10 import '../log.dart';
11
12 typedef void LogFunction(AssetId asset, LogLevel level, String message,
13 SourceSpan span);
14
15 /// Object used to report warnings and errors encountered while running a
16 /// transformer.
17 class TransformLogger {
18 final LogFunction _logFunction;
19
20 TransformLogger(this._logFunction);
21
22 /// Logs an informative message.
23 ///
24 /// If [asset] is provided, the log entry is associated with that asset.
25 /// Otherwise it's associated with the primary input of [transformer]. If
26 /// present, [span] indicates the location in the input asset that caused the
27 /// error.
28 void info(String message, {AssetId asset, SourceSpan span}) {
29 _logFunction(asset, LogLevel.INFO, message, span);
30 }
31
32 /// Logs a message that won't be displayed unless the user is running in
33 /// verbose mode.
34 ///
35 /// If [asset] is provided, the log entry is associated with that asset.
36 /// Otherwise it's associated with the primary input of [transformer]. If
37 /// present, [span] indicates the location in the input asset that caused the
38 /// error.
39 void fine(String message, {AssetId asset, SourceSpan span}) {
40 _logFunction(asset, LogLevel.FINE, message, span);
41 }
42
43 /// Logs a warning message.
44 ///
45 /// If [asset] is provided, the log entry is associated with that asset.
46 /// Otherwise it's associated with the primary input of [transformer]. If
47 /// present, [span] indicates the location in the input asset that caused the
48 /// error.
49 void warning(String message, {AssetId asset, SourceSpan span}) {
50 _logFunction(asset, LogLevel.WARNING, message, span);
51 }
52
53 /// Logs an error message.
54 ///
55 /// If [asset] is provided, the log entry is associated with that asset.
56 /// Otherwise it's associated with the primary input of [transformer]. If
57 /// present, [span] indicates the location in the input asset that caused the
58 /// error.
59 ///
60 /// Logging any errors will cause Barback to consider the transformation to
61 /// have failed, much like throwing an exception. This means that neither the
62 /// primary input nor any outputs emitted by the transformer will be passed on
63 /// to the following phase, and the build will be reported as having failed.
64 ///
65 /// Unlike throwing an exception, this doesn't cause a transformer to stop
66 /// running. This makes it useful in cases where a single input may have
67 /// multiple errors that the user wants to know about.
68 void error(String message, {AssetId asset, SourceSpan span}) {
69 _logFunction(asset, LogLevel.ERROR, message, span);
70 }
71 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/transformer/transform.dart ('k') | pkg/barback/lib/src/transformer/transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698