Skip to content

Commit

Permalink
Merge pull request #2410 from leancodepl/allow-user-to-disable-patrol…
Browse files Browse the repository at this point in the history
…-logging

Add option to disable printing patrol logs in patrol finders
  • Loading branch information
pdenert authored Nov 13, 2024
2 parents 28c8dec + c64b138 commit d681d27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/patrol_finders/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.3.0

- Add option to disable printing patrol logs. Default value is disabled.

## 2.2.0+1

- Bump `patrol_log` version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class PatrolTesterConfig {
this.settlePolicy = SettlePolicy.trySettle,
this.dragDuration = const Duration(milliseconds: 100),
this.settleBetweenScrollsTimeout = const Duration(seconds: 5),
this.printLogs = false,
});

/// Time after which [PatrolFinder.waitUntilExists] fails if it doesn't find
Expand Down Expand Up @@ -53,6 +54,9 @@ class PatrolTesterConfig {
/// [settlePolicy]).
final Duration settleBetweenScrollsTimeout;

/// If true, patrol finders logs will be printed to the console.
final bool printLogs;

/// Creates a copy of this config but with the given fields replaced with the
/// new values.
PatrolTesterConfig copyWith({
Expand All @@ -61,13 +65,18 @@ class PatrolTesterConfig {
Duration? settleTimeout,
SettlePolicy? settlePolicy,
Duration? dragDuration,
Duration? settleBetweenScrollsTimeout,
bool? printLogs,
}) {
return PatrolTesterConfig(
existsTimeout: existsTimeout ?? this.existsTimeout,
visibleTimeout: visibleTimeout ?? this.visibleTimeout,
settleTimeout: settleTimeout ?? this.settleTimeout,
settlePolicy: settlePolicy ?? this.settlePolicy,
dragDuration: dragDuration ?? this.dragDuration,
settleBetweenScrollsTimeout:
settleBetweenScrollsTimeout ?? this.settleBetweenScrollsTimeout,
printLogs: printLogs ?? this.printLogs,
);
}
}
Expand Down Expand Up @@ -140,7 +149,7 @@ class PatrolTester {
required Future<T> Function() function,
bool enablePatrolLog = true,
}) async {
if (!enablePatrolLog) {
if (!(config.printLogs && enablePatrolLog)) {
return function();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/patrol_finders/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: patrol_finders
description: Streamlined, high-level API on top of flutter_test.
version: 2.2.0+1
version: 2.3.0
homepage: https://patrol.leancode.co
repository: https://github.com/leancodepl/patrol/tree/master/packages/patrol_finders
issue_tracker: https://github.com/leancodepl/patrol/issues?q=is%3Aopen+is%3Aissue+label%3Apackage%3Apatrol_finders
Expand Down

0 comments on commit d681d27

Please sign in to comment.