Skip to content

Commit 3ec5735

Browse files
authored
[native_toolchain_c] Add a default Logger (#2661)
Bug: * #2645 The log level is defaulted to `INFO`. Looking at various places in the code base that's a desired level. However, we could consider also swapping it to `WARNING`. Side note: Maybe we'll have less logging messages once we support a dedicated progress update: * #2439
1 parent e5089ea commit 3ec5735

File tree

25 files changed

+59
-170
lines changed

25 files changed

+59
-170
lines changed

pkgs/code_assets/example/mini_audio/hook/build.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:code_assets/code_assets.dart';
66
import 'package:hooks/hooks.dart';
7-
import 'package:logging/logging.dart';
87
import 'package:native_toolchain_c/native_toolchain_c.dart';
98

109
void main(List<String> args) async {
@@ -20,13 +19,7 @@ void main(List<String> args) async {
2019
'MA_API': '__declspec(dllexport)',
2120
},
2221
);
23-
await builder.run(
24-
input: input,
25-
output: output,
26-
logger: Logger('')
27-
..level = Level.ALL
28-
..onRecord.listen((record) => print(record.message)),
29-
);
22+
await builder.run(input: input, output: output);
3023
}
3124
});
3225
}

pkgs/code_assets/example/sqlite/hook/build.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:code_assets/code_assets.dart';
66
import 'package:hooks/hooks.dart';
7-
import 'package:logging/logging.dart';
87
import 'package:native_toolchain_c/native_toolchain_c.dart';
98

109
void main(List<String> args) async {
@@ -20,13 +19,7 @@ void main(List<String> args) async {
2019
'SQLITE_API': '__declspec(dllexport)',
2120
},
2221
);
23-
await builder.run(
24-
input: input,
25-
output: output,
26-
logger: Logger('')
27-
..level = Level.ALL
28-
..onRecord.listen((record) => print(record.message)),
29-
);
22+
await builder.run(input: input, output: output);
3023
}
3124
});
3225
}

pkgs/code_assets/example/stb_image/hook/build.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:code_assets/code_assets.dart';
66
import 'package:hooks/hooks.dart';
7-
import 'package:logging/logging.dart';
87
import 'package:native_toolchain_c/native_toolchain_c.dart';
98

109
void main(List<String> args) async {
@@ -20,13 +19,7 @@ void main(List<String> args) async {
2019
'STBIDEF': '__declspec(dllexport)',
2120
},
2221
);
23-
await builder.run(
24-
input: input,
25-
output: output,
26-
logger: Logger('')
27-
..level = Level.ALL
28-
..onRecord.listen((record) => print(record.message)),
29-
);
22+
await builder.run(input: input, output: output);
3023
}
3124
});
3225
}

pkgs/hooks/example/api/build_snippet_1.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
// snippet-start
1010
import 'package:hooks/hooks.dart';
11-
import 'package:logging/logging.dart';
1211
import 'package:native_toolchain_c/native_toolchain_c.dart';
1312

1413
void main(List<String> args) async {
@@ -19,13 +18,7 @@ void main(List<String> args) async {
1918
assetName: '$packageName.dart',
2019
sources: ['src/$packageName.c'],
2120
);
22-
await cbuilder.run(
23-
input: input,
24-
output: output,
25-
logger: Logger('')
26-
..level = Level.ALL
27-
..onRecord.listen((record) => print(record.message)),
28-
);
21+
await cbuilder.run(input: input, output: output);
2922
});
3023
}
3124

pkgs/hooks/example/api/builder_snippet.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
// snippet-start
1010
import 'package:hooks/hooks.dart';
11-
import 'package:logging/logging.dart';
1211
import 'package:native_toolchain_c/native_toolchain_c.dart';
1312

1413
void main(List<String> args) async {
@@ -19,13 +18,7 @@ void main(List<String> args) async {
1918
assetName: '$packageName.dart',
2019
sources: ['src/$packageName.c'],
2120
);
22-
await cbuilder.run(
23-
input: input,
24-
output: output,
25-
logger: Logger('')
26-
..level = Level.ALL
27-
..onRecord.listen((record) => print(record.message)),
28-
);
21+
await cbuilder.run(input: input, output: output);
2922
});
3023
}
3124

pkgs/hooks/example/build/download_asset/lib/src/hook_helpers/c_build.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:code_assets/code_assets.dart';
66
import 'package:hooks/hooks.dart';
7-
import 'package:logging/logging.dart';
87
import 'package:native_toolchain_c/native_toolchain_c.dart';
98

109
/// Builds the C code for the native_add example.
@@ -21,13 +20,7 @@ Future<void> runBuild(BuildInput input, BuildOutputBuilder output) async {
2120
assetName: 'native_add.dart',
2221
sources: ['src/native_add.c'],
2322
);
24-
await cbuilder.run(
25-
input: input,
26-
output: output,
27-
logger: Logger('')
28-
..level = Level.ALL
29-
..onRecord.listen((record) => print(record.message)),
30-
);
23+
await cbuilder.run(input: input, output: output);
3124
}
3225

3326
/// Creates a target name based on the OS, architecture, and iOS SDK.

pkgs/hooks/example/build/native_add_library/hook/build.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:hooks/hooks.dart';
6-
import 'package:logging/logging.dart';
76
import 'package:native_toolchain_c/native_toolchain_c.dart';
87

98
void main(List<String> args) async {
@@ -14,12 +13,6 @@ void main(List<String> args) async {
1413
assetName: '$packageName.dart',
1514
sources: ['src/$packageName.c'],
1615
);
17-
await cbuilder.run(
18-
input: input,
19-
output: output,
20-
logger: Logger('')
21-
..level = Level.ALL
22-
..onRecord.listen((record) => print(record.message)),
23-
);
16+
await cbuilder.run(input: input, output: output);
2417
});
2518
}

pkgs/hooks/example/build/native_dynamic_linking/hook/build.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:hooks/hooks.dart';
6-
import 'package:logging/logging.dart';
76
import 'package:native_toolchain_c/native_toolchain_c.dart';
87

98
void main(List<String> args) async {
109
await build(args, (input, output) async {
11-
final logger = Logger('')
12-
..level = Level.ALL
13-
..onRecord.listen((record) => print(record.message));
14-
1510
final builders = [
1611
CBuilder.library(
1712
name: 'debug',
@@ -35,7 +30,7 @@ void main(List<String> args) async {
3530
// Note: These builders need to be run sequentially because they depend on
3631
// each others output.
3732
for (final builder in builders) {
38-
await builder.run(input: input, output: output, logger: logger);
33+
await builder.run(input: input, output: output);
3934
}
4035
});
4136
}

pkgs/hooks/example/build/use_dart_api/hook/build.dart

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:hooks/hooks.dart';
6-
import 'package:logging/logging.dart';
76
import 'package:native_toolchain_c/native_toolchain_c.dart';
87

98
void main(List<String> arguments) async {
@@ -14,14 +13,6 @@ void main(List<String> arguments) async {
1413
assetName: 'src/${packageName}_bindings_generated.dart',
1514
sources: ['src/$packageName.c', 'src/dart_api_dl.c'],
1615
);
17-
await cbuilder.run(
18-
input: input,
19-
output: output,
20-
logger: Logger('')
21-
..level = Level.ALL
22-
..onRecord.listen((record) {
23-
print('${record.level.name}: ${record.time}: ${record.message}');
24-
}),
25-
);
16+
await cbuilder.run(input: input, output: output);
2617
});
2718
}

pkgs/hooks/lib/src/api/build_and_link.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import '../validation.dart';
2323
/// <!-- file://./../../../example/api/build_snippet_1.dart -->
2424
/// ```dart
2525
/// import 'package:hooks/hooks.dart';
26-
/// import 'package:logging/logging.dart';
2726
/// import 'package:native_toolchain_c/native_toolchain_c.dart';
2827
///
2928
/// void main(List<String> args) async {
@@ -34,13 +33,7 @@ import '../validation.dart';
3433
/// assetName: '$packageName.dart',
3534
/// sources: ['src/$packageName.c'],
3635
/// );
37-
/// await cbuilder.run(
38-
/// input: input,
39-
/// output: output,
40-
/// logger: Logger('')
41-
/// ..level = Level.ALL
42-
/// ..onRecord.listen((record) => print(record.message)),
43-
/// );
36+
/// await cbuilder.run(input: input, output: output);
4437
/// });
4538
/// }
4639
/// ```

0 commit comments

Comments
 (0)