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

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

Issue 26572010: Improve barback/pub logging. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing file. Created 7 years, 2 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
Index: pkg/barback/lib/src/transform_node.dart
diff --git a/pkg/barback/lib/src/transform_node.dart b/pkg/barback/lib/src/transform_node.dart
index 578b2fa20c8301b95cce949507f8ff91e626a5bd..56605c2617e63e8f9a877d96beb40cbace5d3eb5 100644
--- a/pkg/barback/lib/src/transform_node.dart
+++ b/pkg/barback/lib/src/transform_node.dart
@@ -10,6 +10,7 @@ import 'asset.dart';
import 'asset_id.dart';
import 'asset_node.dart';
import 'asset_set.dart';
+import 'barback_logger.dart';
import 'errors.dart';
import 'phase.dart';
import 'transform.dart';
@@ -53,6 +54,10 @@ class TransformNode {
Stream get onDirty => _onDirtyController.stream;
final _onDirtyController = new StreamController.broadcast(sync: true);
+ /// A stream that emits an event whenever this transform logs an entry.
+ Stream<LogEntry> get onLog => _onLogController.stream;
+ final _onLogController = new StreamController<LogEntry>.broadcast();
+
TransformNode(this.phase, this.transformer, this.primary) {
_primarySubscription = primary.onStateChange.listen((state) {
if (state.isRemoved) {
@@ -106,7 +111,7 @@ class TransformNode {
assert(!_onDirtyController.isClosed);
var newOutputs = new AssetSet();
- var transform = createTransform(this, newOutputs);
+ var transform = createTransform(this, newOutputs, _log);
// Clear all the old input subscriptions. If an input is re-used, we'll
// re-subscribe.
@@ -200,4 +205,12 @@ class TransformNode {
return brandNewOutputs;
}
+
+ void _log(AssetId asset, LogLevel level, String message, Span span) {
+ // If the log isn't already associated with an asset, use the primary.
+ if (asset == null) asset = primary.id;
+ var info = new TransformInfo(transformer, primary.id);
nweiz 2013/10/16 19:41:27 There's already an info getter that does this.
Bob Nystrom 2013/10/28 23:45:56 Done.
+ var entry = new LogEntry(info, asset, level, message, span);
+ _onLogController.add(entry);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698