11library angular2.src.transform.common.logging;
22
33import 'dart:async' ;
4+ import 'dart:io' show stderr;
45
56import 'package:barback/barback.dart' ;
67import 'package:source_span/source_span.dart' ;
@@ -49,12 +50,16 @@ void _logElapsed(Stopwatch timer, String operationName, AssetId assetId) {
4950 log.fine (buf.toString (), asset: assetId);
5051}
5152
52- /// Prints logged messages to the console .
53+ /// Writes logged messages to the provided [StringSink] .
5354///
54- /// A simple implementation of [TransformLogger] that prints messages to the
55- /// console and discards `asset` and `span` information.
56- class PrintLogger implements TransformLogger {
57- void _printWithPrefix (prefix, msg) => print ('$prefix : $msg ' );
55+ /// A simple implementation of [TransformLogger] that writes messages to a
56+ /// [StringSink] and discards `asset` and `span` information.
57+ class SinkLogger implements TransformLogger {
58+ final StringSink _sink;
59+
60+ SinkLogger (this ._sink);
61+
62+ void _printWithPrefix (prefix, msg) => _sink.writeln ('$prefix : $msg ' );
5863
5964 @override
6065 void info (msg, {AssetId asset, SourceSpan span}) =>
@@ -74,6 +79,14 @@ class PrintLogger implements TransformLogger {
7479 }
7580}
7681
82+ /// Prints logged messages to stderr.
83+ ///
84+ /// A simple implementation of [TransformLogger] that prints messages to
85+ /// [stderr] and discards `asset` and `span` information.
86+ class PrintLogger extends SinkLogger {
87+ PrintLogger () : super (stderr);
88+ }
89+
7790class PrintLoggerError extends Error {
7891 final String message;
7992 final AssetId asset;
0 commit comments