Skip to content

Commit f508ef4

Browse files
committed
fix: log some realtime records with level FINE
1 parent 13d6f3a commit f508ef4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/realtime_client/lib/src/realtime_client.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ class RealtimeClient {
171171
}
172172

173173
try {
174-
log('transport', 'connecting to $endPointURL');
174+
log('transport', 'connecting to $endPointURL', null);
175+
log('transport', 'connecting', null, Level.FINE);
175176
connState = SocketStates.connecting;
176177
conn = transport(endPointURL, headers);
177178

@@ -219,7 +220,8 @@ class RealtimeClient {
219220
if (conn != null) {
220221
final oldState = connState;
221222
connState = SocketStates.disconnecting;
222-
log('transport', 'disconnecting', {'code': code, 'reason': reason});
223+
log('transport', 'disconnecting', {'code': code, 'reason': reason},
224+
Level.FINE);
223225

224226
// Connection cannot be closed while it's still connecting. Wait for connection to
225227
// be ready and then close it.
@@ -236,7 +238,7 @@ class RealtimeClient {
236238
}
237239
connState = SocketStates.disconnected;
238240
reconnectTimer.reset();
239-
log('transport', 'disconnected');
241+
log('transport', 'disconnected', null, Level.FINE);
240242
}
241243
this.conn = null;
242244

@@ -265,8 +267,11 @@ class RealtimeClient {
265267
}
266268

267269
/// Logs the message. Override `this.logger` for specialized logging.
268-
void log([String? kind, String? msg, dynamic data]) {
269-
_log.finest('$kind: $msg', data);
270+
///
271+
/// [level] must be [Level.FINEST] for senitive data
272+
void log(
273+
[String? kind, String? msg, dynamic data, Level level = Level.FINEST]) {
274+
_log.log(level, '$kind: $msg', data);
270275
logger?.call(kind, msg, data);
271276
}
272277

@@ -425,6 +430,7 @@ class RealtimeClient {
425430

426431
void _onConnOpen() {
427432
log('transport', 'connected to $endPointURL');
433+
log('transport', 'connected', null, Level.FINE);
428434
_flushSendBuffer();
429435
reconnectTimer.reset();
430436
if (heartbeatTimer != null) heartbeatTimer!.cancel();
@@ -444,7 +450,7 @@ class RealtimeClient {
444450
if (statusCode != null) {
445451
event = RealtimeCloseEvent(code: statusCode, reason: conn?.closeReason);
446452
}
447-
log('transport', 'close', event);
453+
log('transport', 'close', event, Level.FINE);
448454

449455
/// SocketStates.disconnected: by user with socket.disconnect()
450456
/// SocketStates.closed: NOT by user, should try to reconnect

0 commit comments

Comments
 (0)