diff --git a/modules/angular2/src/transform/common/logging.dart b/modules/angular2/src/transform/common/logging.dart index e137b910f2..9637541f51 100644 --- a/modules/angular2/src/transform/common/logging.dart +++ b/modules/angular2/src/transform/common/logging.dart @@ -10,6 +10,11 @@ void init(Transform t) { _logger = new BuildLogger(t); } +/// Sets [logger] directly. Used for testing - in general use [init]. +void setLogger(BuildLogger logger) { + _logger = logger; +} + /// The logger the transformer should use for messaging. BuildLogger get logger { if (_logger == null) { diff --git a/modules/angular2/test/transform/common/logger.dart b/modules/angular2/test/transform/common/logger.dart new file mode 100644 index 0000000000..8e3fba7b6e --- /dev/null +++ b/modules/angular2/test/transform/common/logger.dart @@ -0,0 +1,23 @@ +library angular2.test.transform.common.logger; + +import 'package:code_transformers/messages/build_logger.dart'; + +class NullLogger implements BuildLogger { + const NullLogger(); + void info(String message, {AssetId asset, SourceSpan span}) {} + void fine(String message, {AssetId asset, SourceSpan span}) {} + void warning(String message, {AssetId asset, SourceSpan span}) {} + void error(String message, {AssetId asset, SourceSpan span}) { + throw new NullLoggerError(message, asset, span); + } + Future writeOutput() => null; + Future addLogFilesFromAsset(AssetId id, [int nextNumber = 1]) => null; +} + +class NullLoggerError extends Error { + final String message; + final AssetId asset; + final SourceSpan span; + + NullLoggerError(message, asset, span); +}