Skip to content

Commit c1691e9

Browse files
authored
Use logging in AOT compiler (#4142)
This reduces the number of lines printed by `dart test`, from ~700 to ~530. 🎉 Work towards #4030
1 parent e644857 commit c1691e9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tool/mustachio/codegen_aot_compiler.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:analyzer/dart/element/type_provider.dart';
1010
import 'package:analyzer/dart/element/type_system.dart';
1111
import 'package:collection/collection.dart';
1212
import 'package:dart_style/dart_style.dart';
13+
import 'package:dartdoc/src/logging.dart';
1314
import 'package:dartdoc/src/mustachio/annotations.dart';
1415
import 'package:dartdoc/src/mustachio/parser.dart';
1516
import 'package:dartdoc/src/mustachio/renderer_base.dart';
@@ -32,7 +33,8 @@ Future<String> compileTemplatesToRenderers(
3233
}) async {
3334
var buildData = _BuildData(typeProvider, typeSystem, sourcePath, root);
3435
var referenceUris = <String>{};
35-
print('Compiling ${specs.length} renderer specs into renderer functions...');
36+
logInfo(
37+
'Compiling ${specs.length} renderer specs into renderer functions...');
3638
for (var spec in specs) {
3739
var templatePath = spec.standardHtmlTemplate;
3840
var compiler = await _AotCompiler._readAndParse(
@@ -113,7 +115,7 @@ Future<void> _deduplicateRenderers(
113115
) async {
114116
var initialRendererCount = rendererCache.rendererCount;
115117
if (initialRendererCount < 2) return;
116-
print('Deduplicating the initial set of $initialRendererCount partial '
118+
logInfo('Deduplicating the initial set of $initialRendererCount partial '
117119
'renderer functions...');
118120

119121
var partialsCompilersToRemove = <_AotCompiler>{};
@@ -176,7 +178,7 @@ Future<void> _deduplicateRenderers(
176178
if (names.length > 5) {
177179
names = [...names.take(5), '... (${names.length - 5} more)'];
178180
}
179-
print("Could not deduplicate '$templatePath' with context types: "
181+
logInfo("Could not deduplicate '$templatePath' with context types: "
180182
'$contextStackTypes, from ${names.join(', ')}');
181183
// Any partials generated before the exception was thrown are not needed.
182184
markCompilerForRemoval(lubCompiler);
@@ -202,7 +204,7 @@ Future<void> _deduplicateRenderers(
202204
rendererCache.remove(compiler._templatePath, compiler._usedContextStack);
203205
}
204206

205-
print('Deduplicated down to ${rendererCache.rendererCount} '
207+
logInfo('Deduplicated down to ${rendererCache.rendererCount} '
206208
'partial renderer functions.');
207209
}
208210

@@ -212,8 +214,8 @@ Future<String> _redirectingMethod(
212214
_AotCompiler compiler, _AotCompiler lubCompiler) async {
213215
var buffer = StringBuffer()..write('String ${compiler._rendererName}');
214216

215-
buffer.writeTypeParameters(compiler._usedContextStack
216-
.expand((c) => c.type.element.typeParameters));
217+
buffer.writeTypeParameters(
218+
compiler._usedContextStack.expand((c) => c.type.element.typeParameters));
217219
buffer.write('(');
218220

219221
for (var context in compiler._usedContextStack) {

0 commit comments

Comments
 (0)