2222#include < quic/handshake/CryptoFactory.h>
2323#include < quic/happyeyeballs/QuicHappyEyeballsFunctions.h>
2424#include < quic/logging/QLoggerConstants.h>
25+ #include < quic/logging/QLoggerMacros.h>
2526#include < quic/loss/QuicLossFunctions.h>
2627#include < quic/state/AckHandlers.h>
2728#include < quic/state/DatagramHandlers.h>
@@ -92,9 +93,7 @@ QuicClientTransportLite::QuicClientTransportLite(
9293 clientConn_->initialDestinationConnectionId ;
9394 MVVLOG (4 ) << " initial dcid: "
9495 << clientConn_->initialDestinationConnectionId ->hex ();
95- if (conn_->qLogger ) {
96- conn_->qLogger ->setDcid (conn_->clientChosenDestConnectionId );
97- }
96+ QLOG (*conn_, setDcid, conn_->clientChosenDestConnectionId );
9897
9998 conn_->readCodec ->setCodecParameters (CodecParameters (
10099 conn_->peerAckDelayExponent ,
@@ -251,9 +250,7 @@ quic::Expected<void, QuicError> QuicClientTransportLite::processUdpPacketData(
251250
252251 RetryPacket* retryPacket = parsedPacket.retryPacket ();
253252 if (retryPacket) {
254- if (conn_->qLogger ) {
255- conn_->qLogger ->addPacket (*retryPacket, packetSize, true );
256- }
253+ QLOG (*conn_, addPacket, *retryPacket, packetSize, true );
257254
258255 // we reject retry packet if our initial has been processed or we've rx'd a
259256 // prior retry packet; note that initialAckState is reset to nullptr only
@@ -325,10 +322,11 @@ quic::Expected<void, QuicError> QuicClientTransportLite::processUdpPacketData(
325322 udpPacket.timings ,
326323 udpPacket.tosValue ),
327324 peerAddress);
328- if (conn_->qLogger ) {
329- conn_->qLogger ->addPacketBuffered (
330- cipherUnavailable->protectionType , packetSize);
331- }
325+ QLOG (
326+ *conn_,
327+ addPacketBuffered,
328+ cipherUnavailable->protectionType ,
329+ packetSize);
332330 // Packet buffered, not an error
333331 return {};
334332 }
@@ -358,9 +356,7 @@ quic::Expected<void, QuicError> QuicClientTransportLite::processUdpPacketData(
358356 MVVLOG (4 ) << " Packet parse error for " << *this ;
359357 QUIC_STATS (
360358 statsCallback_, onPacketDropped, PacketDropReason::PARSE_ERROR_CLIENT);
361- if (conn_->qLogger ) {
362- conn_->qLogger ->addPacketDrop (packetSize, kParse );
363- }
359+ QLOG (*conn_, addPacketDrop, packetSize, kParse );
364360 // If this was a protocol violation, we would return a codec error instead.
365361 // Ignore this case as something that caused a non-codec parse error.
366362 return {};
@@ -375,11 +371,11 @@ quic::Expected<void, QuicError> QuicClientTransportLite::processUdpPacketData(
375371 conn_->statsCallback ,
376372 onPacketDropped,
377373 PacketDropReason::PROTOCOL_VIOLATION);
378- if (conn_-> qLogger ) {
379- conn_-> qLogger -> addPacketDrop (
380- packetSize ,
381- PacketDropReason (PacketDropReason::PROTOCOL_VIOLATION). _to_string ());
382- }
374+ QLOG (
375+ * conn_,
376+ addPacketDrop ,
377+ packetSize,
378+ PacketDropReason (PacketDropReason::PROTOCOL_VIOLATION). _to_string ());
383379 return quic::make_unexpected (QuicError (
384380 TransportErrorCode::PROTOCOL_VIOLATION, " Packet has no frames" ));
385381 }
@@ -399,9 +395,7 @@ quic::Expected<void, QuicError> QuicClientTransportLite::processUdpPacketData(
399395 protectionLevel == ProtectionType::KeyPhaseOne;
400396
401397 auto & regularPacket = *regularOptional;
402- if (conn_->qLogger ) {
403- conn_->qLogger ->addPacket (regularPacket, packetSize);
404- }
398+ QLOG (*conn_, addPacket, regularPacket, packetSize);
405399 if (!isProtectedPacket) {
406400 for (auto & quicFrame : regularPacket.frames ) {
407401 auto isPadding = quicFrame.asPaddingFrame ();
@@ -853,9 +847,7 @@ quic::Expected<void, QuicError> QuicClientTransportLite::processUdpPacketData(
853847 clientConn_->zeroRttRejected = handshakeLayer->getZeroRttRejected ();
854848 if (clientConn_->zeroRttRejected .has_value () &&
855849 *clientConn_->zeroRttRejected ) {
856- if (conn_->qLogger ) {
857- conn_->qLogger ->addTransportStateUpdate (kZeroRttRejected );
858- }
850+ QLOG (*conn_, addTransportStateUpdate, kZeroRttRejected );
859851 QUIC_STATS (conn_->statsCallback , onZeroRttRejected);
860852 handshakeLayer->removePsk (hostname_);
861853 if (!handshakeLayer->getCanResendZeroRtt ().value_or (false )) {
@@ -864,9 +856,7 @@ quic::Expected<void, QuicError> QuicClientTransportLite::processUdpPacketData(
864856 " Zero-rtt attempted but the early parameters do not match the handshake parameters" ));
865857 }
866858 } else if (clientConn_->zeroRttRejected .has_value ()) {
867- if (conn_->qLogger ) {
868- conn_->qLogger ->addTransportStateUpdate (kZeroRttAccepted );
869- }
859+ QLOG (*conn_, addTransportStateUpdate, kZeroRttAccepted );
870860 QUIC_STATS (conn_->statsCallback , onZeroRttAccepted);
871861 conn_->usedZeroRtt = true ;
872862 }
@@ -1048,9 +1038,7 @@ quic::Expected<void, QuicError> QuicClientTransportLite::onReadData(
10481038 // If we are closed, then we shouldn't process new network data.
10491039 QUIC_STATS (
10501040 statsCallback_, onPacketDropped, PacketDropReason::CLIENT_STATE_CLOSED);
1051- if (conn_->qLogger ) {
1052- conn_->qLogger ->addPacketDrop (0 , kAlreadyClosed );
1053- }
1041+ QLOG (*conn_, addPacketDrop, 0 , kAlreadyClosed );
10541042 return {};
10551043 }
10561044 bool waitingForFirstPacket = !hasReceivedUdpPackets (*conn_);
@@ -1964,9 +1952,7 @@ void QuicClientTransportLite::start(
19641952
19651953 CHECK (conn_->peerAddress .isInitialized ());
19661954
1967- if (conn_->qLogger ) {
1968- conn_->qLogger ->addTransportStateUpdate (kStart );
1969- }
1955+ QLOG (*conn_, addTransportStateUpdate, kStart );
19701956
19711957 setConnectionSetupCallback (connSetupCb);
19721958 setConnectionCallback (connCb);
@@ -2267,9 +2253,7 @@ quic::Expected<void, QuicError> QuicClientTransportLite::migrateConnection(
22672253 return quic::make_unexpected (adjustResult.error ());
22682254 }
22692255
2270- if (conn_->qLogger ) {
2271- conn_->qLogger ->addConnectionMigrationUpdate (true );
2272- }
2256+ QLOG (*conn_, addConnectionMigrationUpdate, true );
22732257
22742258 QUIC_STATS (conn_->statsCallback , onConnectionMigration);
22752259
@@ -2307,9 +2291,7 @@ void QuicClientTransportLite::setTransportStatsCallback(
23072291}
23082292
23092293void QuicClientTransportLite::maybeQlogDatagram (size_t len) {
2310- if (conn_->qLogger ) {
2311- conn_->qLogger ->addDatagramReceived (len);
2312- }
2294+ QLOG (*conn_, addDatagramReceived, len);
23132295}
23142296
23152297void QuicClientTransportLite::trackDatagramsReceived (
0 commit comments