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

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

Issue 48993007: Revise barback logging patch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. 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
« no previous file with comments | « pkg/barback/lib/src/log.dart ('k') | pkg/barback/lib/src/phase.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/package_graph.dart
diff --git a/pkg/barback/lib/src/package_graph.dart b/pkg/barback/lib/src/package_graph.dart
index dcc3d7f5bb1a9eb9bfc8215929e5e728500dc1d9..95ecbb1546dc91107157fed512d9cc0d979f18d1 100644
--- a/pkg/barback/lib/src/package_graph.dart
+++ b/pkg/barback/lib/src/package_graph.dart
@@ -10,9 +10,9 @@ import 'asset_cascade.dart';
import 'asset_id.dart';
import 'asset_node.dart';
import 'asset_set.dart';
-import 'barback_logger.dart';
import 'build_result.dart';
import 'errors.dart';
+import 'log.dart';
import 'package_provider.dart';
import 'pool.dart';
import 'transformer.dart';
@@ -26,10 +26,6 @@ class PackageGraph {
/// The provider that exposes asset and package information.
final PackageProvider provider;
- /// The logger used to report transformer log entries. If this is null, then
- /// [_defaultLogger] will be used instead.
- final BarbackLogger _logger;
-
/// The [AssetCascade] for each package.
final _cascades = <String, AssetCascade>{};
@@ -60,6 +56,10 @@ class PackageGraph {
Stream<BarbackException> get errors => _errors;
Stream<BarbackException> _errors;
+ /// The stream of [LogEntry] objects used to report transformer log entries.
+ Stream<LogEntry> get log => _logController.stream;
+ final _logController = new StreamController<LogEntry>.broadcast();
+
/// The most recent error emitted from a cascade's result stream.
///
/// This is used to pipe an unexpected error from a build to the resulting
@@ -75,8 +75,7 @@ class PackageGraph {
/// Creates a new [PackageGraph] that will transform assets in all packages
/// made available by [provider].
- PackageGraph(this.provider, {BarbackLogger logger})
- : _logger = logger != null ? logger : new BarbackLogger() {
+ PackageGraph(this.provider) {
for (var package in provider.packages) {
var cascade = new AssetCascade(this, package);
// The initial result for each cascade is "success" since the cascade
@@ -87,7 +86,23 @@ class PackageGraph {
_cascadeResults[package] = null;
});
- cascade.onLog.listen(_logger.logEntry);
+ cascade.onLog.listen((entry) {
+ if (_logController.hasListener) {
+ _logController.add(entry);
+ } else {
+ // No listeners, so just print entry.
+ var buffer = new StringBuffer();
+ buffer.write("[${entry.level} ${entry.transform}] ");
+
+ if (entry.span != null) {
+ buffer.write(entry.span.getLocationMessage(entry.message));
+ } else {
+ buffer.write(entry.message);
+ }
+
+ print(buffer);
+ }
+ });
cascade.results.listen((result) {
_cascadeResults[cascade.package] = result;
« no previous file with comments | « pkg/barback/lib/src/log.dart ('k') | pkg/barback/lib/src/phase.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698