Skip to content

Commit

Permalink
Use Logger.detached for test loggers (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaugold authored Oct 16, 2023
1 parent 22f4481 commit 757f503
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkgs/native_assets_builder/test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Logger _createTestLogger({
List<String>? capturedMessages,
Level level = Level.ALL,
}) =>
Logger('')
Logger.detached('')
..level = level
..onRecord.listen((record) {
printOnFailure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void main() {
].first.uri;
final ld = [
...await appleLd.defaultResolver!.resolve(logger: logger),
...await lib.defaultResolver!.resolve(logger: logger),
...await link.defaultResolver!.resolve(logger: logger),
...await lld.defaultResolver!.resolve(logger: logger),
].first.uri;
final envScript = [
Expand Down
14 changes: 8 additions & 6 deletions pkgs/native_toolchain_c/test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ Logger? _logger;
Logger createCapturingLogger(List<String> capturedMessages) =>
_createTestLogger(capturedMessages: capturedMessages);

Logger _createTestLogger({List<String>? capturedMessages}) => Logger('')
..level = Level.ALL
..onRecord.listen((record) {
printOnFailure('${record.level.name}: ${record.time}: ${record.message}');
capturedMessages?.add(record.message);
});
Logger _createTestLogger({List<String>? capturedMessages}) =>
Logger.detached('')
..level = Level.ALL
..onRecord.listen((record) {
printOnFailure(
'${record.level.name}: ${record.time}: ${record.message}');
capturedMessages?.add(record.message);
});

/// Test files are run in a variety of ways, find this package root in all.
///
Expand Down

0 comments on commit 757f503

Please sign in to comment.