refactor(dart/transform): Improve logging
Ensure that, where possible, log messages include an [AssetId]. Closes #5369
This commit is contained in:
parent
cee67e6fe0
commit
9ae171e0c8
|
@ -56,8 +56,10 @@ class ReflectionInfoVisitor extends RecursiveAstVisitor<ReflectionInfoModel> {
|
||||||
if (numCtorsFound > 1) {
|
if (numCtorsFound > 1) {
|
||||||
var ctorName = ctor.name;
|
var ctorName = ctor.name;
|
||||||
if (ctorName != null) {
|
if (ctorName != null) {
|
||||||
log.warning('Found ${numCtorsFound} constructors for class '
|
log.warning(
|
||||||
'${node.name}; using constructor ${ctorName}.');
|
'Found ${numCtorsFound} constructors for class '
|
||||||
|
'${node.name}; using constructor ${ctorName}.',
|
||||||
|
asset: assetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ctor;
|
return ctor;
|
||||||
|
@ -166,8 +168,10 @@ class ReflectionInfoVisitor extends RecursiveAstVisitor<ReflectionInfoModel> {
|
||||||
if (directivesNode == null) return const [];
|
if (directivesNode == null) return const [];
|
||||||
|
|
||||||
if (directivesNode.expression is! ListLiteral) {
|
if (directivesNode.expression is! ListLiteral) {
|
||||||
log.warning('Angular 2 expects a list literal for `directives` '
|
log.warning(
|
||||||
'but found a ${directivesNode.expression.runtimeType}');
|
'Angular 2 expects a list literal for `directives` '
|
||||||
|
'but found a ${directivesNode.expression.runtimeType}',
|
||||||
|
asset: assetId);
|
||||||
return const [];
|
return const [];
|
||||||
}
|
}
|
||||||
final directives = <PrefixedDirective>[];
|
final directives = <PrefixedDirective>[];
|
||||||
|
@ -179,7 +183,8 @@ class ReflectionInfoVisitor extends RecursiveAstVisitor<ReflectionInfoModel> {
|
||||||
} else if (dep is Identifier) {
|
} else if (dep is Identifier) {
|
||||||
directives.add(new PrefixedDirective()..name = '${dep}');
|
directives.add(new PrefixedDirective()..name = '${dep}');
|
||||||
} else {
|
} else {
|
||||||
log.warning('Found unexpected value $dep in `directives`.');
|
log.warning('Found unexpected value $dep in `directives`.',
|
||||||
|
asset: assetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return directives;
|
return directives;
|
||||||
|
|
|
@ -114,12 +114,13 @@ class _FindDeferredLibraries extends Object with RecursiveAstVisitor<Object> {
|
||||||
|
|
||||||
bool hasDeferredLibrariesToRewrite() {
|
bool hasDeferredLibrariesToRewrite() {
|
||||||
if (deferredImports.isEmpty) {
|
if (deferredImports.isEmpty) {
|
||||||
log.fine('There are no deferred library imports.');
|
log.fine('There are no deferred library imports.', asset: _entryPoint);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (loadLibraryInvocations.isEmpty) {
|
if (loadLibraryInvocations.isEmpty) {
|
||||||
log.fine(
|
log.fine(
|
||||||
'There are no loadLibrary invocations that need to be rewritten.');
|
'There are no loadLibrary invocations that need to be rewritten.',
|
||||||
|
asset: _entryPoint);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -72,9 +72,11 @@ Future<Map<String, String>> _processNgImports(NgDepsModel model,
|
||||||
retVal[directive.uri] = summaryJsonUri;
|
retVal[directive.uri] = summaryJsonUri;
|
||||||
}
|
}
|
||||||
}, onError: (err, stack) {
|
}, onError: (err, stack) {
|
||||||
log.warning('Error while looking for $summaryJsonUri. '
|
log.warning(
|
||||||
|
'Error while looking for $summaryJsonUri. '
|
||||||
'Message: $err\n'
|
'Message: $err\n'
|
||||||
'Stack: $stack');
|
'Stack: $stack',
|
||||||
|
asset: assetId);
|
||||||
});
|
});
|
||||||
}))
|
}))
|
||||||
.then((_) => retVal);
|
.then((_) => retVal);
|
||||||
|
|
|
@ -77,7 +77,7 @@ Future _linkRecursive(NgMeta ngMeta, AssetReader reader, AssetId assetId,
|
||||||
}
|
}
|
||||||
} catch (err, st) {
|
} catch (err, st) {
|
||||||
// Log and continue.
|
// Log and continue.
|
||||||
log.warning('Failed to fetch $uri. Message: $err.\n$st');
|
log.warning('Failed to fetch $uri. Message: $err.\n$st', asset: assetId);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ class _NgMetaVisitor extends Object with SimpleAstVisitor<Object> {
|
||||||
compileDirectiveMetadata;
|
compileDirectiveMetadata;
|
||||||
}
|
}
|
||||||
}).catchError((err) {
|
}).catchError((err) {
|
||||||
log.error('ERROR: $err');
|
log.error('ERROR: $err', asset: assetId);
|
||||||
}));
|
}));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ class _ViewPropInliner extends RecursiveAstVisitor<Object> {
|
||||||
final inlinedVal = _addInlineValue(url, varBase: _inlinedStyleBase);
|
final inlinedVal = _addInlineValue(url, varBase: _inlinedStyleBase);
|
||||||
_writer.print('${inlinedVal.name},');
|
_writer.print('${inlinedVal.name},');
|
||||||
} else {
|
} else {
|
||||||
zone.log.warning('style url is not a String (${url})');
|
zone.log.warning('style url is not a String (${url})', asset: _assetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_writer.print(']');
|
_writer.print(']');
|
||||||
|
@ -191,7 +191,8 @@ class _ViewPropInliner extends RecursiveAstVisitor<Object> {
|
||||||
void _populateTemplateUrl(NamedExpression node) {
|
void _populateTemplateUrl(NamedExpression node) {
|
||||||
var url = naiveEval(node.expression);
|
var url = naiveEval(node.expression);
|
||||||
if (url is! String) {
|
if (url is! String) {
|
||||||
zone.log.warning('template url is not a String (${node.expression})');
|
zone.log.warning('template url is not a String (${node.expression})',
|
||||||
|
asset: _assetId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_writer.print(_code.substring(_lastIndex, node.offset));
|
_writer.print(_code.substring(_lastIndex, node.offset));
|
||||||
|
@ -209,7 +210,7 @@ class _ViewPropInliner extends RecursiveAstVisitor<Object> {
|
||||||
final resolvedUri = _urlResolver.resolve(_baseUri.toString(), url);
|
final resolvedUri = _urlResolver.resolve(_baseUri.toString(), url);
|
||||||
|
|
||||||
return _xhr.get(resolvedUri).catchError((_) {
|
return _xhr.get(resolvedUri).catchError((_) {
|
||||||
zone.log.error('$_baseUri: could not read $url');
|
zone.log.error('$_baseUri: could not read $url', asset: _assetId);
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,11 @@ class ReflectionRemover extends Transformer implements LazyTransformer {
|
||||||
if (options.modeName == TRANSFORM_DYNAMIC_MODE) {
|
if (options.modeName == TRANSFORM_DYNAMIC_MODE) {
|
||||||
mirrorMode = MirrorMode.debug;
|
mirrorMode = MirrorMode.debug;
|
||||||
writeStaticInit = false;
|
writeStaticInit = false;
|
||||||
zone.log.info('Running in "${options.modeName}", '
|
zone.log.info(
|
||||||
|
'Running in "${options.modeName}", '
|
||||||
'mirrorMode: ${mirrorMode}, '
|
'mirrorMode: ${mirrorMode}, '
|
||||||
'writeStaticInit: ${writeStaticInit}.');
|
'writeStaticInit: ${writeStaticInit}.',
|
||||||
|
asset: primaryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
var transformedCode = await removeReflectionCapabilities(
|
var transformedCode = await removeReflectionCapabilities(
|
||||||
|
|
|
@ -19,8 +19,8 @@ import 'package:barback/barback.dart';
|
||||||
///
|
///
|
||||||
/// The returned value wraps the [NgDepsModel] at `assetId` as well as these
|
/// The returned value wraps the [NgDepsModel] at `assetId` as well as these
|
||||||
/// created objects.
|
/// created objects.
|
||||||
Future<CompileDataResults> createCompileData(
|
Future<CompileDataResults> createCompileData(AssetReader reader,
|
||||||
AssetReader reader, AssetId assetId, List<String> platformDirectives) async {
|
AssetId assetId, List<String> platformDirectives) async {
|
||||||
return logElapsedAsync(() async {
|
return logElapsedAsync(() async {
|
||||||
final creator =
|
final creator =
|
||||||
await _CompileDataCreator.create(reader, assetId, platformDirectives);
|
await _CompileDataCreator.create(reader, assetId, platformDirectives);
|
||||||
|
@ -92,10 +92,12 @@ class _CompileDataCreator {
|
||||||
} else if (depNgMeta.aliases.containsKey(dep.name)) {
|
} else if (depNgMeta.aliases.containsKey(dep.name)) {
|
||||||
compileDatum.directives.addAll(depNgMeta.flatten(dep.name));
|
compileDatum.directives.addAll(depNgMeta.flatten(dep.name));
|
||||||
} else {
|
} else {
|
||||||
log.warning('Could not find Directive entry for $dep. '
|
log.warning(
|
||||||
|
'Could not find Directive entry for $dep. '
|
||||||
'Please be aware that Dart transformers have limited support for '
|
'Please be aware that Dart transformers have limited support for '
|
||||||
'reusable, pre-defined lists of Directives (aka '
|
'reusable, pre-defined lists of Directives (aka '
|
||||||
'"directive aliases"). See https://goo.gl/d8XPt0 for details.');
|
'"directive aliases"). See https://goo.gl/d8XPt0 for details.',
|
||||||
|
asset: entryPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileData[reflectable] = compileDatum;
|
compileData[reflectable] = compileDatum;
|
||||||
|
@ -112,8 +114,10 @@ class _CompileDataCreator {
|
||||||
for (var ad in platformDirectives) {
|
for (var ad in platformDirectives) {
|
||||||
final parts = ad.split("#");
|
final parts = ad.split("#");
|
||||||
if (parts.length != 2) {
|
if (parts.length != 2) {
|
||||||
log.warning('The platform directives configuration option '
|
log.warning(
|
||||||
'must be in the following format: "URI#TOKEN"');
|
'The platform directives configuration option '
|
||||||
|
'must be in the following format: "URI#TOKEN"',
|
||||||
|
asset: entryPoint);
|
||||||
return const [];
|
return const [];
|
||||||
}
|
}
|
||||||
res.addAll(await _readPlatformDirectivesFromUri(parts[0], parts[1]));
|
res.addAll(await _readPlatformDirectivesFromUri(parts[0], parts[1]));
|
||||||
|
|
Loading…
Reference in New Issue