Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 3da9c5c

Browse files
committed
refactor(postgres): inject logger dependency into client
Modifies the HtDataPostgresClient to accept a Logger instance via its constructor instead of creating one internally. This change improves testability by allowing mock loggers to be injected and follows the Dependency Inversion Principle, giving the consumer full control over logger configuration and hierarchy.
1 parent 3945a3c commit 3da9c5c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/src/ht_data_postgres.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ class HtDataPostgresClient<T> implements HtDataClient<T> {
1818
required this.tableName,
1919
required this.fromJson,
2020
required this.toJson,
21-
}) : _queryBuilder = _QueryBuilder(tableName: tableName);
21+
required Logger log,
22+
}) : _queryBuilder = _QueryBuilder(tableName: tableName),
23+
_log = log;
2224

23-
final _log = Logger('HtDataPostgresClient<$T>');
25+
final Logger _log;
2426

2527
/// The active PostgreSQL database connection.
2628
final Connection connection;

0 commit comments

Comments
 (0)