Skip to content

Commit da66f9f

Browse files
committed
fix: log headers with level FINEST
1 parent 44a693a commit da66f9f

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

packages/functions_client/lib/src/functions_client.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class FunctionsClient {
2828
_isolate = isolate ?? (YAJsonIsolate()..initialize()),
2929
_hasCustomIsolate = isolate != null,
3030
_httpClient = httpClient {
31-
_log.config("Initialize FunctionsClient v$version");
31+
_log.config("Initialize FunctionsClient v$version with url: $url");
32+
_log.finest("Initialize with headers: $headers");
3233
}
3334

3435
/// Getter for the headers

packages/gotrue/lib/src/gotrue_client.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,22 @@ class GoTrueClient {
105105
GotrueAsyncStorage? asyncStorage,
106106
AuthFlowType flowType = AuthFlowType.pkce,
107107
}) : _url = url ?? Constants.defaultGotrueUrl,
108-
_headers = headers ?? {},
108+
_headers = {
109+
...Constants.defaultHeaders,
110+
...?headers,
111+
},
109112
_httpClient = httpClient,
110113
_asyncStorage = asyncStorage,
111114
_flowType = flowType {
112115
_autoRefreshToken = autoRefreshToken ?? true;
113116

117+
final gotrueUrl = url ?? Constants.defaultGotrueUrl;
114118
_log.config(
115119
'Initialize GoTrueClient v$version with url: $_url, autoRefreshToken: $_autoRefreshToken, flowType: $_flowType, tickDuration: ${Constants.autoRefreshTickDuration}, tickThreshold: ${Constants.autoRefreshTickThreshold}');
116-
117-
final gotrueUrl = url ?? Constants.defaultGotrueUrl;
118-
final gotrueHeader = {
119-
...Constants.defaultHeaders,
120-
if (headers != null) ...headers,
121-
};
120+
_log.finest('Initialize with headers: $_headers');
122121
admin = GoTrueAdminApi(
123122
gotrueUrl,
124-
headers: gotrueHeader,
123+
headers: _headers,
125124
httpClient: httpClient,
126125
);
127126
mfa = GoTrueMFAApi(

packages/postgrest/lib/src/postgrest.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ class PostgrestClient {
3434
}) : _schema = schema,
3535
headers = {...defaultHeaders, if (headers != null) ...headers},
3636
_isolate = isolate ?? (YAJsonIsolate()..initialize()),
37-
_hasCustomIsolate = isolate != null;
37+
_hasCustomIsolate = isolate != null {
38+
_log.config('Initialize PostgrestClient with url: $url, schema: $_schema');
39+
_log.finest('Initialize with headers: $headers');
40+
}
3841

3942
/// Authenticates the request with JWT.
4043
@Deprecated("Use setAuth() instead")

packages/realtime_client/lib/src/realtime_client.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class RealtimeClient {
140140
if (headers != null) ...headers,
141141
},
142142
transport = transport ?? createWebSocketClient {
143+
_log.config(
144+
'Initialize RealtimeClient with endpoint: $endPoint, timeout: $timeout, heartbeatIntervalMs: $heartbeatIntervalMs, longpollerTimeout: $longpollerTimeout, logLevel: $logLevel');
145+
_log.finest('Initialize with headers: $headers, params: $params');
143146
final customJWT = this.headers['Authorization']?.split(' ').last;
144147
accessToken = customJWT ?? params['apikey'];
145148

packages/storage_client/lib/src/storage_client.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import 'package:http/http.dart';
2+
import 'package:logging/logging.dart';
23
import 'package:storage_client/src/constants.dart';
34
import 'package:storage_client/src/storage_bucket_api.dart';
45
import 'package:storage_client/src/storage_file_api.dart';
6+
import 'package:storage_client/src/version.dart';
57

68
class SupabaseStorageClient extends StorageBucketApi {
79
final int _defaultRetryAttempts;
10+
final _log = Logger('supabase.storage');
811

912
/// To create a [SupabaseStorageClient], you need to provide an [url] and [headers].
1013
///
@@ -42,7 +45,11 @@ class SupabaseStorageClient extends StorageBucketApi {
4245
url,
4346
{...Constants.defaultHeaders, ...headers},
4447
httpClient: httpClient,
45-
);
48+
) {
49+
_log.config(
50+
'Initialize SupabaseStorageClient v$version with url: $url, retryAttempts: $_defaultRetryAttempts');
51+
_log.finest('Initialize with headers: $headers');
52+
}
4653

4754
/// Perform file operation in a bucket.
4855
///

0 commit comments

Comments
 (0)