fix(dart/transform): Gracefully handle log calls before init

- Lazily create and use a logger that prints instead of `throw`ing.
- Use this logger in unit tests.
This commit is contained in:
Tim Blasi
2015-04-09 17:42:14 -07:00
parent cac74c73e1
commit bba849909c
4 changed files with 31 additions and 28 deletions
@@ -1,23 +0,0 @@
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);
}