diff --git a/packages/moxxmpp_socket_tcp/CHANGELOG.md b/packages/moxxmpp_socket_tcp/CHANGELOG.md index d0a7586..5902472 100644 --- a/packages/moxxmpp_socket_tcp/CHANGELOG.md +++ b/packages/moxxmpp_socket_tcp/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.0 + +- Keep version in sync with moxxmpp +- *BREAKING*: `TCPSocketWrapper` now takes a boolean parameter that enables logging of all incoming and outgoing data. + ## 0.3.1 - Keep version in sync with moxxmpp diff --git a/packages/moxxmpp_socket_tcp/integration_test/badxmpp_certificate_test.dart b/packages/moxxmpp_socket_tcp/integration_test/badxmpp_certificate_test.dart index 25e7aa9..b4c5a7d 100644 --- a/packages/moxxmpp_socket_tcp/integration_test/badxmpp_certificate_test.dart +++ b/packages/moxxmpp_socket_tcp/integration_test/badxmpp_certificate_test.dart @@ -5,7 +5,7 @@ import 'package:test/test.dart'; Future _runTest(String domain) async { var gotTLSException = false; - final socket = TCPSocketWrapper(); + final socket = TCPSocketWrapper(true); final log = Logger('TestLogger'); socket.getEventStream().listen((event) { if (event is XmppSocketTLSFailedEvent) { diff --git a/packages/moxxmpp_socket_tcp/integration_test/failure_reconnection_test.dart b/packages/moxxmpp_socket_tcp/integration_test/failure_reconnection_test.dart index d9eb4d0..4d012c0 100644 --- a/packages/moxxmpp_socket_tcp/integration_test/failure_reconnection_test.dart +++ b/packages/moxxmpp_socket_tcp/integration_test/failure_reconnection_test.dart @@ -19,7 +19,7 @@ void main() { TestingSleepReconnectionPolicy(10), AlwaysConnectedConnectivityManager(), ClientToServerNegotiator(), - TCPSocketWrapper(), + TCPSocketWrapper(true), )..connectionSettings = ConnectionSettings( jid: JID.fromString('testuser@no-sasl.badxmpp.eu'), password: 'abc123', @@ -59,7 +59,7 @@ void main() { TestingReconnectionPolicy(), AlwaysConnectedConnectivityManager(), ClientToServerNegotiator(), - TCPSocketWrapper(), + TCPSocketWrapper(true), )..connectionSettings = ConnectionSettings( jid: JID.fromString('testuser@no-sasl.badxmpp.eu'), password: 'abc123', diff --git a/packages/moxxmpp_socket_tcp/lib/src/socket.dart b/packages/moxxmpp_socket_tcp/lib/src/socket.dart index 7922bdc..ce2e6c6 100644 --- a/packages/moxxmpp_socket_tcp/lib/src/socket.dart +++ b/packages/moxxmpp_socket_tcp/lib/src/socket.dart @@ -10,6 +10,11 @@ import 'package:moxxmpp_socket_tcp/src/rfc_2782.dart'; /// TCP socket implementation for XmppConnection class TCPSocketWrapper extends BaseSocketWrapper { + TCPSocketWrapper(this._logIncomingOutgoing); + + /// Flag controlling whether incoming/outgoing data is logged or not. + final bool _logIncomingOutgoing; + /// The underlying Socket/SecureSocket instance. Socket? _socket; @@ -212,7 +217,9 @@ class TCPSocketWrapper extends BaseSocketWrapper { _socketSubscription = _socket!.listen( (List event) { final data = utf8.decode(event); - _log.finest('<== $data'); + if (_logIncomingOutgoing) { + _log.finest('<== $data'); + } _dataStream.add(data); }, onError: (Object error) { @@ -297,7 +304,9 @@ class TCPSocketWrapper extends BaseSocketWrapper { return; } - _log.finest('==> $data'); + if (_logIncomingOutgoing) { + _log.finest('==> $data'); + } try { _socket!.write(data);