diff --git a/Sources/SwiftNetwork/EndpointFlow/EndpointFlowProtocols.swift b/Sources/SwiftNetwork/EndpointFlow/EndpointFlowProtocols.swift index 0e64ac1..ae649ee 100644 --- a/Sources/SwiftNetwork/EndpointFlow/EndpointFlowProtocols.swift +++ b/Sources/SwiftNetwork/EndpointFlow/EndpointFlowProtocols.swift @@ -179,7 +179,6 @@ class EndpointFlowProtocol: ProtocolInstanceCon } public func start() { - log.debug("start") fromExternal { lower.invokeConnect(reference) } @@ -197,7 +196,6 @@ class EndpointFlowProtocol: ProtocolInstanceCon } public func stop() { - log.debug("stop") fromExternal { lower.invokeDisconnect(reference) } diff --git a/Sources/SwiftNetwork/Protocols/BridgeProtocol.swift b/Sources/SwiftNetwork/Protocols/BridgeProtocol.swift index cca0c8b..c00d721 100644 --- a/Sources/SwiftNetwork/Protocols/BridgeProtocol.swift +++ b/Sources/SwiftNetwork/Protocols/BridgeProtocol.swift @@ -253,7 +253,7 @@ public struct BridgeDatagramProtocol: NetworkProtocol { public func sendDatagrams(_ datagrams: consuming FrameArray) throws(NetworkError) { let remotePort = remoteEndpoint!.port guard let remoteInstance = BridgeInstance.instances[remotePort] else { - log.error("unable to find instance for port: \(remotePort)") + log.error("Unable to find instance for port: \(remotePort)") datagrams.finalizeAllFramesAsFailed() return } @@ -430,7 +430,7 @@ public struct BridgeStreamProtocol: NetworkProtocol { public func sendStreamData(_ streamData: consuming FrameArray) throws(NetworkError) { let remotePort = remoteEndpoint!.port guard let remoteInstance = BridgeInstance.instances[remotePort] else { - log.error("unable to find instance for port: \(remotePort)") + log.error("Unable to find instance for port: \(remotePort)") streamData.finalizeAllFramesAsFailed() return } diff --git a/Sources/SwiftNetwork/Protocols/HarnessProtocols.swift b/Sources/SwiftNetwork/Protocols/HarnessProtocols.swift index 429a8c1..cfb2edf 100644 --- a/Sources/SwiftNetwork/Protocols/HarnessProtocols.swift +++ b/Sources/SwiftNetwork/Protocols/HarnessProtocols.swift @@ -184,7 +184,6 @@ public class UpperHarness: UpperHarnessProtocol } public func start() { - log.debug("start") invokeConnect() } @@ -194,7 +193,6 @@ public class UpperHarness: UpperHarnessProtocol } public func stop(error: NetworkError? = nil) { - log.debug("stop") invokeDisconnect(error: error) } @@ -684,7 +682,7 @@ public class DatagramLowerHarness: LowerHarness, Bottom public func receiveDatagrams(maximumDatagramCount: Int) throws(NetworkError) -> FrameArray? { let array = pendingInboundPackets.drainArray(maximumFrameCount: maximumDatagramCount) - log.debug("deliver inbound datagram count: \(array.count)") + log.debug("Deliver inbound datagram count: \(array.count)") return array } diff --git a/Sources/SwiftNetwork/QUIC/Ack.swift b/Sources/SwiftNetwork/QUIC/Ack.swift index 9984f41..c08b384 100644 --- a/Sources/SwiftNetwork/QUIC/Ack.swift +++ b/Sources/SwiftNetwork/QUIC/Ack.swift @@ -223,7 +223,7 @@ struct AckSpace: ~Copyable, PrefixedLoggable { return 0 } guard _slowPath(largestTimestamp != .zero) else { - log.debug("largest PN receive time can't be 0 (\(packetNumberSpace))") + log.debug("Largest PN receive time can't be 0 (\(packetNumberSpace))") return 0 } let largest = lastBlock.end @@ -828,7 +828,7 @@ final class Ack: PrefixedLoggable, TimerUser { func flush(for packetNumberSpace: PacketNumberSpace) { withAckSpace(packetNumberSpace: packetNumberSpace) { ackSpace in - log.debug("flushing all PN for \(packetNumberSpace)") + log.debug("Flushing all PN for \(packetNumberSpace)") ackSpace.blocks = [] ackSpace.needsTransmission = false return true @@ -978,13 +978,13 @@ struct AckBitstring: ~Copyable { let initialWord = initialWord if _slowPath(startWord < initialWord) { Logger.proto.fault( - "initial word \(initialWord) is lower than start \(startWord) (pn \(start))" + "Initial word \(initialWord) is lower than start \(startWord) (pn \(start))" ) return false } if _slowPath(stopWord < initialWord) { Logger.proto.fault( - "initial word \(initialWord) is lower than stop \(stopWord) (pn \(stop))" + "Initial word \(initialWord) is lower than stop \(stopWord) (pn \(stop))" ) return false } @@ -1004,13 +1004,13 @@ struct AckBitstring: ~Copyable { let initialWord = initialWord if _slowPath(startWord > initialWord + bitstringCount) { Logger.proto.fault( - "size \(bitstringCount + initialWord) is lower than start \(startWord) (pn \(start))" + "Size \(bitstringCount + initialWord) is lower than start \(startWord) (pn \(start))" ) return false } if _slowPath(stopWord > initialWord + bitstringCount) { Logger.proto.fault( - "size \(bitstringCount + initialWord) is lower than start \(stopWord) (pn \(stop))" + "Size \(bitstringCount + initialWord) is lower than start \(stopWord) (pn \(stop))" ) return false } @@ -1028,7 +1028,7 @@ struct AckBitstring: ~Copyable { if stopWord >= size { guard _slowPath(stopWord < UInt32.max / 2) else { - Logger.proto.info("refusing to grow bitstring further") + Logger.proto.info("Refusing to grow bitstring further") return } let targetSize = Int(stopWord) + 1 @@ -1074,7 +1074,7 @@ struct AckBitstring: ~Copyable { guard initialWord == other.initialWord else { let initialWord = self.initialWord let otherInitialWord = other.initialWord - Logger.proto.fault("bitstring initial mismatch \(initialWord) != \(otherInitialWord)") + Logger.proto.fault("Bitstring initial mismatch \(initialWord) != \(otherInitialWord)") return AckBitstringSequence.empty } if size > other.size { diff --git a/Sources/SwiftNetwork/QUIC/CongestionControl.swift b/Sources/SwiftNetwork/QUIC/CongestionControl.swift index b96b352..f72f75c 100644 --- a/Sources/SwiftNetwork/QUIC/CongestionControl.swift +++ b/Sources/SwiftNetwork/QUIC/CongestionControl.swift @@ -474,7 +474,7 @@ extension CongestionControlProtocol { ) { congestionEvent(sentTime: largestAckSentTime, mss: mss, qlog: qlog) log.debug( - "link was flow controlled, reduced congestion window is \(congestionWindow) bytes" + "Link was flow controlled, reduced congestion window is \(congestionWindow) bytes" ) } diff --git a/Sources/SwiftNetwork/QUIC/Crypto.swift b/Sources/SwiftNetwork/QUIC/Crypto.swift index cebbe8d..3c84f54 100644 --- a/Sources/SwiftNetwork/QUIC/Crypto.swift +++ b/Sources/SwiftNetwork/QUIC/Crypto.swift @@ -361,7 +361,7 @@ extension QUICCrypto: TopStreamProtocol, ProtocolInstanceContainer { func handleConnectedEvent() { guard let parentConnection else { return } - parentConnection.log.info("connected: TLS finished") + parentConnection.log.info("Connected: TLS finished") parentConnection.fromExternal { parentConnection.reportReady() } diff --git a/Sources/SwiftNetwork/QUIC/Cubic.swift b/Sources/SwiftNetwork/QUIC/Cubic.swift index 88326c1..5004758 100644 --- a/Sources/SwiftNetwork/QUIC/Cubic.swift +++ b/Sources/SwiftNetwork/QUIC/Cubic.swift @@ -345,7 +345,7 @@ struct Cubic: CongestionControlProtocol, CubicLikeProtocol { ) { if _slowPath(ceCount < ecnCECounter) { log.fault( - "new CE count \(ceCount) can't be less than current CE count \(ecnCECounter)" + "New CE count \(ceCount) can't be less than current CE count \(ecnCECounter)" ) } // Update packets acked and marked on every ACK, even if it diff --git a/Sources/SwiftNetwork/QUIC/ECN.swift b/Sources/SwiftNetwork/QUIC/ECN.swift index 21d116f..db08bd8 100644 --- a/Sources/SwiftNetwork/QUIC/ECN.swift +++ b/Sources/SwiftNetwork/QUIC/ECN.swift @@ -151,7 +151,7 @@ struct ECN: ~Copyable, PrefixedLoggable { } path.ecnState?.resetValidationCounters() log.info( - "enable ECN echo: \(path.ecnState?.echoEnabled ?? false), enable ECN: \(path.ecnState?.ecnMarkingEnabled ?? false) use ECT(1): \(path.ecnState?.useECT1 ?? false)" + "Enable ECN echo: \(path.ecnState?.echoEnabled ?? false), enable ECN: \(path.ecnState?.ecnMarkingEnabled ?? false) use ECT(1): \(path.ecnState?.useECT1 ?? false)" ) } for i in 0..= baseRTT else { - log.fault("param check returned false") + log.fault("currentRTT lower than baseRTT") return } let qDelay = currentRTT - baseRTT @@ -238,7 +238,7 @@ struct Ledbat: CongestionControlProtocol, CubicLikeProtocol { ) { if _slowPath(ceCount < ecnCECounter) { log.fault( - "new CE count \(ceCount) can't be less than current CE count \(ecnCECounter)" + "New CE count \(ceCount) can't be less than current CE count \(ecnCECounter)" ) } // Update packets acked and marked on every ACK, even if it diff --git a/Sources/SwiftNetwork/QUIC/PMTUD.swift b/Sources/SwiftNetwork/QUIC/PMTUD.swift index 8820934..8f66667 100644 --- a/Sources/SwiftNetwork/QUIC/PMTUD.swift +++ b/Sources/SwiftNetwork/QUIC/PMTUD.swift @@ -232,24 +232,24 @@ struct PMTUDState: ~Copyable { if !enabled { return } - path.log.info("received ICMP packet too big MTU: \(nextMTU)") + path.log.info("Received ICMP packet too big MTU: \(nextMTU)") if nextMTU < PMTUDState.minimumMTU { - path.log.info("ignore packet too big MTU < minimum MTU: \(PMTUDState.minimumMTU)") + path.log.info("Ignore packet too big MTU < minimum MTU: \(PMTUDState.minimumMTU)") } else if nextMTU == currentPathMTU { path.log.info( - "finished searching: packet too big MTU == current MTU: \(currentPathMTU)" + "Finished searching: packet too big MTU == current MTU: \(currentPathMTU)" ) searchComplete(on: path) } else if nextMTU > probedMTU { - path.log.info("ignore packet too big MTU > probed size: \(probedMTU)") + path.log.info("Ignore packet too big MTU > probed size: \(probedMTU)") } else if PMTUDState.minimumMTU <= nextMTU && nextMTU < currentPathMTU { - path.log.info("packet too big MTU < current path MTU \(currentPathMTU)") + path.log.info("Packet too big MTU < current path MTU \(currentPathMTU)") packetTooBigMTU = (packetTooBigMTU == 0) ? nextMTU : min(packetTooBigMTU, nextMTU) path.parentProtocol.recordSentPackets { enterBlackholeDetection(on: path) } } else if currentPathMTU < nextMTU && nextMTU < probedMTU { - path.log.info("current path MTU < packet too big MTU size < probed MTU") + path.log.info("Current path MTU < packet too big MTU size < probed MTU") packetTooBigMTU = (packetTooBigMTU == 0) ? nextMTU : min(packetTooBigMTU, nextMTU) } } @@ -306,9 +306,9 @@ struct PMTUDState: ~Copyable { } failedProbeCount += 1 - path.log.info("lost probe for MTU \(lostMTU), probe count \(failedProbeCount)") + path.log.info("Lost probe for MTU \(lostMTU), probe count \(failedProbeCount)") if failedProbeCount == PMTUDState.maxProbeCount { - path.log.info("finish searching: reached maxProbeCount") + path.log.info("Finished searching: reached maxProbeCount") searchComplete(on: path) } else { updateProbeSize(on: path) @@ -382,7 +382,7 @@ struct PMTUDState: ~Copyable { private mutating func enterBlackholeDetection(on path: QUICPath) -> NetworkUniqueDeque { guard enabled else { return .init() } - path.log.info("entering blackhole detection, setting path MTU to \(PMTUDState.minimumMTU)") + path.log.info("Entering blackhole detection, setting path MTU to \(PMTUDState.minimumMTU)") currentPathMTU = PMTUDState.minimumMTU searchCompleted = false failedProbeCount = 0 @@ -467,7 +467,7 @@ struct PMTUDState: ~Copyable { private mutating func updateProbeSize(on path: QUICPath) { if searchCompleted { - Logger.proto.fault("attempt to update probe size while search is completed") + Logger.proto.fault("Attempt to update probe size while search is completed") return } diff --git a/Sources/SwiftNetwork/QUIC/Pacer.swift b/Sources/SwiftNetwork/QUIC/Pacer.swift index a32b110..cd8a033 100644 --- a/Sources/SwiftNetwork/QUIC/Pacer.swift +++ b/Sources/SwiftNetwork/QUIC/Pacer.swift @@ -34,7 +34,7 @@ struct Pacer: ~Copyable { guard rate > 0 else { let startupRate = startupRate Logger.proto.fault( - "pacer rate shouldn't be 0, startup rate = \(startupRate), CCA is \(path.congestionControlName) (cwnd=\(path.congestionControlWindow), smoothed rtt=\(path.smoothedRTT.milliseconds) ms)" + "Pacer rate shouldn't be 0, startup rate = \(startupRate), CCA is \(path.congestionControlName) (cwnd=\(path.congestionControlWindow), smoothed rtt=\(path.smoothedRTT.milliseconds) ms)" ) return Constants.maxBurstIntervalKernelPacing } diff --git a/Sources/SwiftNetwork/QUIC/PacketParser.swift b/Sources/SwiftNetwork/QUIC/PacketParser.swift index 48ee40d..de4506a 100644 --- a/Sources/SwiftNetwork/QUIC/PacketParser.swift +++ b/Sources/SwiftNetwork/QUIC/PacketParser.swift @@ -560,7 +560,7 @@ struct PacketParser: ~Copyable, PrefixedLoggable { do { try connection.protector.openHeader(&packet, frame: &frame) } catch { - connection.log.error("packet number undecryptable") + connection.log.error("Packet number undecryptable") return false } @@ -593,21 +593,21 @@ struct PacketParser: ~Copyable, PrefixedLoggable { func retryTokenPresent(_ frame: inout Frame, token: [UInt8]?) -> Bool { guard let token else { - log.error("token is nil, discarding") + log.error("Token is nil, discarding") return false } guard let firstOctet = try? self.parseFirstOctet(&frame, claim: false) else { - log.error("could not parse first octet from packet") + log.error("Could not parse first octet from packet") return false } let longHeader = (firstOctet & 0x80) != 0 guard longHeader else { - log.error("received invalid packet") + log.error("Received invalid packet") return false } let packetType = (firstOctet & 0x30) >> 4 guard packetType == 0x0 else { - log.error("received packet when expecting Initial with retry token") + log.error("Received packet when expecting Initial with retry token") return false } var dcidLength: UInt8 = 0 @@ -625,7 +625,7 @@ struct PacketParser: ~Copyable, PrefixedLoggable { try read.span(expect: token.span.bytes) } guard result.isValid else { - log.error("could not parse a valid token from the packet") + log.error("Could not parse a valid token from the packet") return false } return true diff --git a/Sources/SwiftNetwork/QUIC/Prague.swift b/Sources/SwiftNetwork/QUIC/Prague.swift index 374e016..4dbbf2f 100644 --- a/Sources/SwiftNetwork/QUIC/Prague.swift +++ b/Sources/SwiftNetwork/QUIC/Prague.swift @@ -543,7 +543,7 @@ struct Prague: CongestionControlProtocol, CubicLikeProtocol { ) { if _slowPath(ceCount < ecnCECounter) { log.fault( - "new CE count \(ceCount) can't be less than current CE count \(ecnCECounter)" + "New CE count \(ceCount) can't be less than current CE count \(ecnCECounter)" ) } diff --git a/Sources/SwiftNetwork/QUIC/Protector.swift b/Sources/SwiftNetwork/QUIC/Protector.swift index b47d0b1..a6ba752 100644 --- a/Sources/SwiftNetwork/QUIC/Protector.swift +++ b/Sources/SwiftNetwork/QUIC/Protector.swift @@ -340,7 +340,7 @@ struct SecFramerAESGCM: ~Copyable, SecFramerProtocol { } } guard result == kCCSuccess else { - keys.log.error("unable to \(loggingOperation) header: \(result)") + keys.log.error("Unable to \(loggingOperation) header: \(result)") throw QUICError.protector(.headerProtectionFailed) } #elseif canImport(CryptoExtras) || NETWORK_STANDALONE @@ -365,7 +365,7 @@ struct SecFramerAESGCM: ~Copyable, SecFramerProtocol { } }.get() } catch { - keys.log.error("unable to \(loggingOperation) header: \(error)") + keys.log.error("Unable to \(loggingOperation) header: \(error)") throw QUICError.protector(.headerProtectionFailed) } #endif @@ -388,7 +388,7 @@ struct SecFramerAESGCM: ~Copyable, SecFramerProtocol { ) #endif guard var buffer = frame.mutableSpan else { - keys.log.error("unclaimed bytes nil") + keys.log.error("Unclaimed bytes nil") throw QUICError.protector(SecFramerError.openFailed) } do { @@ -550,7 +550,7 @@ struct SecFramerChaChaPoly: ~Copyable, SecFramerProtocol { ) #endif guard var buffer = frame.mutableSpan else { - keys.log.error("buffer nil") + keys.log.error("Buffer nil") throw QUICError.protector(SecFramerError.openFailed) } #if !NETWORK_EMBEDDED @@ -767,7 +767,7 @@ struct Protector: ~Copyable, PrefixedLoggable { } mutating func swapFramers(keyState: PacketKeyState) { - log.debug("swapping framers since we're a server") + log.debug("Swapping framers since we're a server") swap(&readFramer[keyState.rawValue], &writeFramer[keyState.rawValue]) } @@ -1312,7 +1312,7 @@ struct Protector: ~Copyable, PrefixedLoggable { tag: retryTag ) } catch { - Logger.proto.error("failed to open retry packet") + Logger.proto.error("Failed to open retry packet") throw QUICError.protector(SecFramerError.openFailed) } } diff --git a/Sources/SwiftNetwork/QUIC/QLog.swift b/Sources/SwiftNetwork/QUIC/QLog.swift index ce9bce8..8bbac7c 100644 --- a/Sources/SwiftNetwork/QUIC/QLog.swift +++ b/Sources/SwiftNetwork/QUIC/QLog.swift @@ -949,7 +949,7 @@ final class QLog { return jsonData } else { let topLevelObject = topLevelObject - Logger.proto.error("error serializing JSON: \(topLevelObject)") + Logger.proto.error("Error serializing JSON: \(topLevelObject)") return nil } } diff --git a/Sources/SwiftNetwork/QUIC/QUICConnection.swift b/Sources/SwiftNetwork/QUIC/QUICConnection.swift index 8056a7f..5ca6914 100644 --- a/Sources/SwiftNetwork/QUIC/QUICConnection.swift +++ b/Sources/SwiftNetwork/QUIC/QUICConnection.swift @@ -584,7 +584,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, log.info("qlog setup with configuration: \(qlogConfiguration)") } #endif - log.info("setup QUIC connection (spin bit \(spinBitEnabled ? "enabled" : "disabled"))") + log.info("Setup QUIC connection (spin bit \(spinBitEnabled ? "enabled" : "disabled"))") } public func setup( @@ -645,10 +645,10 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, let newMaxStreams = max(maximumStreams, self.bidirectionalStreams.localMaxStreams) if newMaxStreams > Constants.maxStreamLimit { self.close(with: .streamLimitError, "MAX_STREAMS value over limit") - self.log.error("received MAX_STREAMS value too large: \(maximumStreams)") + self.log.error("Received MAX_STREAMS value too large: \(maximumStreams)") return } - log.notice("advertising MAX_STREAMS bidi: \(newMaxStreams)") + log.notice("Advertising MAX_STREAMS bidi: \(newMaxStreams)") self.withMutableQUICStreams(unidirectional: false) { mutableStreamsState in mutableStreamsState.updateLocalMaxStreams( @@ -667,10 +667,10 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, let newMaxStreams = max(maximumStreams, self.unidirectionalStreams.localMaxStreams) if newMaxStreams > Constants.maxStreamLimit { self.close(with: .streamLimitError, "MAX_STREAMS value over limit") - self.log.error("received MAX_STREAMS value too large: \(maximumStreams)") + self.log.error("Received MAX_STREAMS value too large: \(maximumStreams)") return } - log.notice("advertising MAX_STREAMS uni: \(newMaxStreams)") + log.notice("Advertising MAX_STREAMS uni: \(newMaxStreams)") self.withMutableQUICStreams(unidirectional: true) { mutableStreamsState in mutableStreamsState.updateLocalMaxStreams( @@ -710,22 +710,22 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // Get handlers self.connectionMetadata.getLocalMaxStreamsBidirectional { let localMaxStreams = UInt64(self.bidirectionalStreams.localMaxStreams) - self.log.debug("local bidi max_streams=\(localMaxStreams)") + self.log.debug("Local bidi max_streams=\(localMaxStreams)") return localMaxStreams } self.connectionMetadata.getLocalMaxStreamsUnidirectional { let localMaxStreams = UInt64(self.unidirectionalStreams.localMaxStreams) - self.log.debug("local uni max_streams=\(localMaxStreams)") + self.log.debug("Local uni max_streams=\(localMaxStreams)") return localMaxStreams } self.connectionMetadata.getRemoteMaxStreamsBidirectional { let remoteMaxStreams = UInt64(self.bidirectionalStreams.remoteMaxStreams) - self.log.debug("remote bidi max_streams=\(remoteMaxStreams)") + self.log.debug("Remote bidi max_streams=\(remoteMaxStreams)") return remoteMaxStreams } self.connectionMetadata.getRemoteMaxStreamsUnidirectional { let remoteMaxStreams = UInt64(self.unidirectionalStreams.remoteMaxStreams) - self.log.debug("remote uni max_streams=\(remoteMaxStreams)") + self.log.debug("Remote uni max_streams=\(remoteMaxStreams)") return remoteMaxStreams } self.connectionMetadata.getKeepalive { @@ -889,7 +889,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, guard let initialSCID = remoteTransportParameters[.initialSCID], initialSCID.connectionID == self.currentPath?.dcid else { - log.error("missing/invalid initial SCID") + log.error("Missing/invalid initial SCID") close(with: .protocolViolation, "missing/invalid initial SCID TP") return } @@ -898,7 +898,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, guard let originalDCID = remoteTransportParameters[.originalDCID], originalDCID.connectionID == self.originalDCID else { - log.error("missing/invalid original DCID") + log.error("Missing/invalid original DCID") close(with: .protocolViolation, "missing/invalid original DCID TP") return } @@ -906,7 +906,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, let retrySCID = remoteTransportParameters[.retrySCID] if retryReceived { guard let retrySCID, retrySCID.connectionID == self.retrySCID else { - log.error("missing/invalid RETRY SCID TP") + log.error("Missing/invalid RETRY SCID TP") close(with: .protocolViolation, "missing/invalid RETRY SCID TP") return } @@ -932,7 +932,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, || remoteTransportParameters[.retrySCID] != nil || remoteTransportParameters[.statelessResetToken] != nil) { - log.error("client sent invalid transport parameters") + log.error("Client sent invalid transport parameters") close(with: .transportParameterError, "invalid TP: ODCID/ISCID/SRT/PA") return } @@ -1235,7 +1235,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, public func connect() { log.debug( - "received connection start (isServer: \(self.isServer))" + "Received connection start (isServer: \(self.isServer))" ) // Defer closing until end of processing connection @@ -1352,10 +1352,10 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, let value = localTransportParameters.intValue(.maxIdleTimeout) if value > 0 { idleTimeout = .milliseconds(value) - log.debug("parameter configured idle timeout: \(self.idleTimeout)") + log.debug("Parameter configured idle timeout: \(self.idleTimeout)") } else { idleTimeout = Constants.defaultIdleTimeout - log.debug("default idle timeout: \(self.idleTimeout)") + log.debug("Default idle timeout: \(self.idleTimeout)") } idleTimerID = timer.insert( @@ -1390,7 +1390,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, (idleTimeoutLocal == 0 || idleTimeoutRemote == 0) ? (idleTimeoutLocal + idleTimeoutRemote) : min(idleTimeoutLocal, idleTimeoutRemote) if minIdleTimeout == 0 { - log.info("idle timeout is not configured by any endpoint, disabling timer") + log.info("Idle timeout is not configured by any endpoint, disabling timer") if let idleTimerID { timer.remove(idleTimerID) } @@ -1406,7 +1406,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // Check when the last activity was recorded let now = NetworkClock.Instant.now guard now >= lastPacketReceivedTimestamp else { - log.fault("now should not be less than lastPacketReceivedTimestamp") + log.fault("Now should not be less than lastPacketReceivedTimestamp") return } let delta = lastPacketReceivedTimestamp.duration(to: now) @@ -1416,7 +1416,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // Only reset the timer if it is at least the threshold from now (1ms) if sleepDuration >= Timer.timerThreshold { - log.debug("idle timer rescheduled for \(sleepDuration)") + log.debug("Idle timer rescheduled for \(sleepDuration)") if let idleTimerID { timer.reschedule( identifier: idleTimerID, @@ -1429,7 +1429,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, } errorToReport = NetworkError.posix(ETIMEDOUT) log.info( - "idle timeout fired, closing connection due to inactivity \(delta) >= \(idleTimeout)" + "Idle timeout fired, closing connection due to inactivity \(delta) >= \(idleTimeout)" ) // No packets need to be sent when the idle timeout fires. @@ -1438,14 +1438,14 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, public func connect(flow flowID: MultiplexedFlowIdentifier) { log.debug( - "received connection start on flow \(flowID.debugDescription) (isServer: \(self.isServer))" + "Received connection start on flow \(flowID.debugDescription) (isServer: \(self.isServer))" ) // For streams (not datagram flows), ensure the stream isn't pending if secondaryFlow(for: flowID) == nil { // If this is a QUICStream then make sure its not in a pending state guard let stream = flow(for: flowID), !stream.pendingStart else { log.error( - "flow \(flowID.debugDescription) cannot go connected because it is pending (isServer: \(self.isServer))" + "Flow \(flowID.debugDescription) cannot go connected because it is pending (isServer: \(self.isServer))" ) return } @@ -1497,7 +1497,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, error: NetworkError? = nil ) { log.debug( - "stopping flow \(flowID.debugDescription) (direction: \(direction))" + "Stopping flow \(flowID.debugDescription) (direction: \(direction))" ) if let error, let applicationError = error.quicApplicationError, @@ -1527,7 +1527,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, } if stream.readClosed, stream.writeClosed { stream.close(errorCode: nil) - stream.log.debug("closed stream") + stream.log.debug("Closed stream") } else { stream.log.debug( "stream.readClosed \(stream.readClosed), stream.writeClosed \(stream.writeClosed)" @@ -1537,7 +1537,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, } else if let _ = secondaryFlow(for: flowID) { deliverDisconnectedEvent(flow: flowID, error: nil) } else { - log.error("no stream for \(flowID), cannot close") + log.error("No stream for \(flowID), cannot close") } if state == .connected { @@ -1631,7 +1631,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // If the retry has been sent, preflight if this is an initial packet with a token. // If so, allow it to proceed through the normal handshake / parsing process guard packetParser.retryTokenPresent(&frame, token: initialToken) else { - log.error("initial packet received in retrySent state without a valid token") + log.error("Initial packet received in retrySent state without a valid token") return } } @@ -1704,9 +1704,9 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, let packet = packetParser.parse(frame: &frame, connection: self, path: path, ecn: ecnFlags) guard var packet else { if state == .connected { - log.error("unable to parse packet") + log.error("Unable to parse packet") } else { - log.info("unable to parse packet (decryption keys may not be ready)") + log.info("Unable to parse packet (decryption keys may not be ready)") } if self.closeError != nil { close() @@ -1792,7 +1792,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, packetKeystate == .initial || packetKeystate == .handshake, !QUICFrame.isAllowedDuringHandshake(frame: quicFrame) { - log.error("invalid frame type during the handshake: \(quicFrame.frameType)") + log.error("Invalid frame type during the handshake: \(quicFrame.frameType)") closeFrameType = quicFrame.frameType close(with: .protocolViolation, "invalid frame type during the handshake") } @@ -1841,13 +1841,13 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, private func handleInboundVersionNegotiation(_ packet: borrowing Packet) { if isServer { // Version negotiation packets can only be sent by the server. - log.error("received a VN packet from a client") + log.error("Received a VN packet from a client") return } // A client MUST ignore a Version Negotiation packet if it has already // received and acted on a Version Negotiation packet. if versionReceived { - log.error("received a second VN") + log.error("Received a second VN") return } @@ -1895,7 +1895,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, recovery.resetPNSpace(packetNumberSpace: .handshake, connection: self) // Resetting congestion control will reset the pacer too currentPath.resetCongestionControl() - log.info("retransmitting INITIAL with version \(version.rawValue)") + log.info("Retransmitting INITIAL with version \(version.rawValue)") // Resetting crypto here will guarantee the initial is sent again crypto.stop() crypto = QUICCrypto(context: context) @@ -1909,30 +1909,30 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, private func handleInboundRetry(_ packet: borrowing Packet) { guard !isServer else { // Retry packets can only be sent by the server. - log.error("received a RETRY packet from a client") + log.error("Received a RETRY packet from a client") return } guard packet.tokenLength > 0, packet.tokenLength <= Constants.retryTokenMaxLength else { - log.error("discarding RETRY with a bad length token") + log.error("Discarding RETRY with a bad length token") return } guard let token = packet.token, let tag = packet.tag else { - log.error("discarding RETRY could not parse token or tag") + log.error("Discarding RETRY could not parse token or tag") return } guard state == .initialSent else { - log.error("received RETRY in state \(state)") + log.error("Received RETRY in state \(state)") return } // After the client has received and processed an // Initial or Retry packet from the server, it MUST discard any // subsequent Retry packets that it receives. guard !retryReceived else { - log.error("received second RETRY") + log.error("Received second RETRY") return } @@ -1941,17 +1941,17 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, let pathSCID = path.scid, let firstOctet = packet.retryFirstOctet else { - log.error("received RETRY with path in a bad state") + log.error("Received RETRY with path in a bad state") return } guard let version = packet.version else { - log.error("received RETRY without a version") + log.error("Received RETRY without a version") return } guard let dcid = packet.destinationConnectionID, let scid = packet.sourceConnectionID else { - log.error("received RETRY with bad CIDs") + log.error("Received RETRY with bad CIDs") return } // From a clients perspective: @@ -1968,7 +1968,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, do throws(QUICError) { try Protector.openRetry(retryPseudo: pseudoRetry.span.bytes, retryTag: tag.span.bytes) } catch { - log.error("unable to authenticate retry with error: \(error)") + log.error("Unable to authenticate retry with error: \(error)") return } guard dcid == pathSCID else { @@ -1989,7 +1989,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // The protector needs to derive new initial keys using the RETRY's SCID as the new DCID protector.deriveInitialSecrets(destinationCID: scid) - log.info("retransmitting INITIAL with token len: \(packet.tokenLength)") + log.info("Retransmitting INITIAL with token len: \(packet.tokenLength)") // Resetting crypto here will guarantee the initial is sent again crypto.stop() crypto = QUICCrypto(context: context) @@ -2092,7 +2092,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, if packet.keyState != .initial { close(with: .protocolViolation, "non-initial packet during VN") log.error( - "bogus server first packet \(packet.keyState?.description ?? "nil"), expecting version negotiation" + "Bogus server first packet \(packet.keyState?.description ?? "nil"), expecting version negotiation" ) return false } @@ -2104,21 +2104,21 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, guard let scid = packet.sourceConnectionID, let dcid = packet.destinationConnectionID else { - log.error("could not extract scid and dcid from long header") + log.error("Could not extract scid and dcid from long header") return false } negotiatedVersion = packet.version state.change(to: .initialReceived, logIDString: logPrefixer.logIDString) keyState = .handshake - log.info("new SCID: \(scid)") + log.info("New SCID: \(scid)") currentPath?.setSCID(scid) - log.info("new DCID: \(dcid)") + log.info("New DCID: \(dcid)") currentPath?.assignDCID(dcid) protector.deriveInitialSecrets(destinationCID: dcid) } else { close(with: .internalError, "version negotiation failed") - log.error("version negotiation failed") + log.error("Version negotiation failed") return false } break @@ -2127,7 +2127,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, guard packet.keyState == .initial else { close(with: .protocolViolation, "bogus server first packet") log.error( - "bogus server first packet \(packet.keyState?.description ?? "nil")" + "Bogus server first packet \(packet.keyState?.description ?? "nil")" ) return false } @@ -2149,7 +2149,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, case .initialProcessed, .handshake, .connected, .retryReceived, .versionReceived, .retrySent: // NOTE: compare token - log.info("state \(state)") + log.info("State \(state)") break case .closing, .draining: @@ -2282,11 +2282,11 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, private func handleInboundShortHeader(_ packet: borrowing Packet, path: QUICPath) -> Bool { guard let packetKeyState = packet.keyState else { - log.error("received short header without keystate set") + log.error("Received short header without keystate set") return false } if packetKeyState != keyState { - log.notice("switching to keystate \(packetKeyState)") + log.notice("Switching to keystate \(packetKeyState)") keyState = packetKeyState } @@ -2402,7 +2402,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, } guard let streamID = stream.streamID else { - log.debug("outbound packet is for an unknown stream ID") + log.debug("Outbound packet is for an unknown stream ID") return } @@ -2563,7 +2563,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, let flowID = stream.identifier log.debug( - "setting up stream for flow ID \(flowID.debugDescription)" + "Setting up stream for flow ID \(flowID.debugDescription)" ) // When connected, this new stream can become ready right away and @@ -2583,7 +2583,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, if streamID == nil { streamBlocked = true log.notice( - "failed to allocate stream ID for flow \(flowID.debugDescription), will be created as pending" + "Failed to allocate stream ID for flow \(flowID.debugDescription), will be created as pending" ) } } else { @@ -2617,11 +2617,11 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, stream.unidirectional = isUnidirectional log.debug( - "set stream \(stream.streamID?.description ?? "nil") for flow \(flowID.debugDescription)" + "Set stream \(stream.streamID?.description ?? "nil") for flow \(flowID.debugDescription)" ) if let streamID { - log.debug("set known flow \(flowID.debugDescription) for key \(streamID)") + log.debug("Set known flow \(flowID.debugDescription) for key \(streamID)") knownFlows[streamID] = flowID if isUnidirectional { self.unidirectionalStreams.incrementActiveStreams() @@ -2630,13 +2630,13 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, } stream.outboundStreamReady() } else { - log.debug("add pending stream for flow \(flowID.debugDescription)") + log.debug("Add pending stream for flow \(flowID.debugDescription)") withMutableQUICStreams(unidirectional: stream.unidirectional) { mutableStreamsState in mutableStreamsState.addPending(stream) } if self.state == .connected && streamBlocked { // Send the STREAMS_*_BLOCKED frame if we are connected. - log.debug("marked stream (flow \(flowID.debugDescription)) as pending") + log.debug("Marked stream (flow \(flowID.debugDescription)) as pending") stream.outboundStreamPending( connected: (self.state == .connected), connection: self @@ -2684,7 +2684,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // Closing all flows, i.e. streams, and the connection itself private func close(sendCloseFrame: Bool = true) { if state.isTerminal || drainingScheduled { - log.debug("already in closing or draining state") + log.debug("Already in closing or draining state") return } isPacing = false @@ -2704,7 +2704,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, space = .handshake } log.debug( - "closing connection in state \(self.state) (PN space \(space))" + "Closing connection in state \(self.state) (PN space \(space))" ) if sendCloseFrame { @@ -2801,13 +2801,13 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, if timeSinceLastReceived + .milliseconds(1) >= keepaliveDuration { if maxKeepaliveCount > 0 && unackedKeepaliveCount >= maxKeepaliveCount { log.error( - "keep-alive timer fired, exceeding \(maxKeepaliveCount) outstanding keep-alives" + "Keep-alive timer fired, exceeding \(maxKeepaliveCount) outstanding keep-alives" ) errorToReport = .posix(ETIMEDOUT) close(with: .noError, "keepalive limit reached") return } - log.info("sending keep-alive frame, already have \(unackedKeepaliveCount) outstanding") + log.info("Sending keep-alive frame, already have \(unackedKeepaliveCount) outstanding") unackedKeepaliveCount += 1 withPendingItems(for: .applicationData) { @@ -2835,13 +2835,13 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // from the remote side. let now = NetworkClock.Instant.now if _slowPath(now < lastPacketReceivedTimestamp) { - log.fault("bogus lastPacketReceivedTimestamp") + log.fault("Bogus lastPacketReceivedTimestamp") return } stats.increment(.keepAliveFramesSent) let timeSinceLastReceived = lastPacketReceivedTimestamp.duration(to: now) log.debug( - "keepalive: now: \(now), last packet: \(self.lastPacketReceivedTimestamp) timeSinceLastReceived: \(timeSinceLastReceived), interval: \(self.keepaliveDuration)" + "Keepalive: now: \(now), last packet: \(self.lastPacketReceivedTimestamp) timeSinceLastReceived: \(timeSinceLastReceived), interval: \(self.keepaliveDuration)" ) keepaliveSendPingFrame(timeSinceLastReceived: timeSinceLastReceived) @@ -2890,14 +2890,14 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, fromNow: .zero, timerNow: self.now ) - log.notice("stopped keep-alive timer") + log.notice("Stopped keep-alive timer") } else if minIdleTime == .zero || keepaliveDuration < minIdleTime { timer.reschedule( identifier: timerID, fromNow: keepaliveDuration, timerNow: self.now ) - log.notice("started keep-alive timer (\(keepaliveDuration)") + log.notice("Started keep-alive timer (\(keepaliveDuration)") } } } @@ -3379,7 +3379,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, availableCongestionWindow = 0 } log.debug( - "setting available congestion window: \(availableCongestionWindow) until the client is validated" + "Setting available congestion window: \(availableCongestionWindow) until the client is validated" ) } guard availableCongestionWindow > 0 || pendingItems.hasNonInFlightEligiblePendingItems @@ -3775,7 +3775,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // Already handled return } - stream.log.debug("read closed") + stream.log.debug("Read closed") if stream.pendingStart { if stream.unidirectional { self.unidirectionalStreams.removePending(stream) @@ -3814,7 +3814,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, ) -> Bool { var closeWrite = true - stream.log.debug("write closed for stream") + stream.log.debug("Write closed for stream") if stream.pendingStart { if stream.unidirectional { unidirectionalStreams.removePending(stream) @@ -3844,7 +3844,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, if stream.hasMoreSendDataToService { stream.log.debug( - "send stream data queue is not empty, deferring close" + "Send stream data queue is not empty, deferring close" ) closeWrite = false } @@ -3905,9 +3905,9 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, } initialToken = _token sendRetry(path: path, packet: packet) - log.notice("new SCID: \(scid)") + log.notice("New SCID: \(scid)") guard let dcid = packet.destinationConnectionID else { - log.error("packet does not contain dcid") + log.error("Packet does not contain dcid") return false } initialDCID = dcid @@ -3936,7 +3936,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, if migration.probingPathCount(self) > 0 { self.stats.increment(.statelessResetDuringPathProbe) } - log.info("received valid stateless reset token") + log.info("Received valid stateless reset token") errorToReport = NetworkError.posix(ECONNRESET) close() } @@ -4118,10 +4118,10 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, guard closeError == nil else { return } if remoteTransportParameters[.disableActiveMigration] != nil { - log.info("peer asked us to disable active migration") + log.info("Peer asked us to disable active migration") migration.disableActiveMigration() } else if !isServer, self.currentPath?.dcid?.length == 0 { - log.info("disabling migration due to zero-length peer CID") + log.info("Disabling migration due to zero-length peer CID") migration.disableActiveMigration() } else { migrationSupported = true @@ -4160,7 +4160,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // Setup all streams and tell all flows that they are ready readyAllOutboundStreams() - log.notice("delivering connected") + log.notice("Delivering connected") deliverConnectedEvent(flow: .allFlows) stats.increment(.connectionAttempts) @@ -4192,7 +4192,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, || initialRemoteMaxStreamsUnidirectional > Constants.maxStreamLimit { log.error( - "received too large max streams value, bidi: \(initialRemoteMaxStreamsBidirectional) uni: \(initialRemoteMaxStreamsUnidirectional)" + "Received too large max streams value, bidi: \(initialRemoteMaxStreamsBidirectional) uni: \(initialRemoteMaxStreamsUnidirectional)" ) close(with: .transportParameterError, "initial FC over limit") return @@ -4225,7 +4225,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, defer { let remoteMaxDatagramFrameSize = remoteMaxDatagramFrameSize log.debug( - "remote max datagram size \(remoteMaxDatagramFrameSize)" + "Remote max datagram size \(remoteMaxDatagramFrameSize)" ) } guard let remoteTPMaxDatagramFrameSize else { @@ -4285,7 +4285,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, guard let streamID = stream.streamID, let _ = knownFlows[streamID] else { - log.error("cannot deliver inbound aborted event: no flow for stream \(stream.streamID?.value ?? 0)") + log.error("Cannot deliver inbound aborted event: no flow for stream \(stream.streamID?.value ?? 0)") return } stream.deliverInboundAbortedEvent(error: error) @@ -4303,7 +4303,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, try deliverEnqueuedInboundStreamData(flow: flowID) sendFrames() } catch { - log.error("error sending frames on stream close: \(error)") + log.error("Error sending frames on stream close: \(error)") } } stream.closed = true @@ -4421,7 +4421,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, isBidirectional: streamID.isBidirectional ) else { - log.fault("next inbound stream id is invalid") + log.fault("Next inbound stream id is invalid") self.closeError = QUICTransportError( .internalError, "inconsistent next inbound stream ID" @@ -4439,14 +4439,14 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, let peer = isServer ? "server" : "client" let streamIntention = isServer ? "client" : "server" log.error( - "peer (\(peer) trying to open \(streamIntention) stream - last : \(largestOutboundStreamID.value)" + "Peer (\(peer) trying to open \(streamIntention) stream - last : \(largestOutboundStreamID.value)" ) self.closeError = QUICTransportError(.streamStateError, "invalid stream ID") return false } } if self.streamIDBlocked(streamID: streamID) { - log.error("stream ID \(streamID.value) exceeded the maximum allowed") + log.error("Stream ID \(streamID.value) exceeded the maximum allowed") self.closeError = QUICTransportError(.streamLimitError, "exceeded maximum stream ID") return false } @@ -4454,7 +4454,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, // because the lookup failed. Don't re-create streams that are // already closed. if streamID.value < nextInboundStreamID.value { - log.info("not recreating closed stream \(streamID.value)") + log.info("Not recreating closed stream \(streamID.value)") return true } else { return false @@ -4477,7 +4477,7 @@ extension QUICConnection { // Process an incoming NEW_TOKEN frame func processNewTokenFrame(_ frame: consuming FrameNewToken) -> Bool { - Logger.proto.info("received NEW_TOKEN frame") + Logger.proto.info("Received NEW_TOKEN frame") // Clients MUST NOT send NEW_TOKEN frames. A server MUST treat receipt of a // NEW_TOKEN frame as a connection error of type PROTOCOL_VIOLATION. @@ -4501,7 +4501,7 @@ extension QUICConnection { "received STREAM frame with id: \(frame.id), offset: \(frame.offset) data length: \(frame.length)" ) guard let streamID = QUICStreamID(frame.id) else { - log.error("stream frame with invalid stream ID \(frame.id)") + log.error("Stream frame with invalid stream ID \(frame.id)") frame.frame.finalize(success: true) return false } @@ -4542,7 +4542,7 @@ extension QUICConnection { return true } guard let stream = flow(for: flowID) else { - log.error("cannot look up stream for flowID \(flowID.debugDescription)") + log.error("Cannot look up stream for flowID \(flowID.debugDescription)") frame.frame.finalize(success: true) return true } @@ -4715,17 +4715,17 @@ extension QUICConnection { ) -> Bool { if maxStreams > Constants.maxStreamLimit { close(with: .streamLimitError, "MAX_STREAMS value over limit") - log.error("received MAX_STREAMS value too large: \(maxStreams)") + log.error("Received MAX_STREAMS value too large: \(maxStreams)") return false } if unidirectional { if self.unidirectionalStreams.remoteMaxStreams >= maxStreams { log.notice( - "new MAX_STREAMS_UNI \(maxStreams) doesn't advance current limit \(self.unidirectionalStreams.remoteMaxStreams)" + "New MAX_STREAMS_UNI \(maxStreams) doesn't advance current limit \(self.unidirectionalStreams.remoteMaxStreams)" ) return true } - log.notice("unidirectional max streams now \(maxStreams)") + log.notice("Unidirectional max streams now \(maxStreams)") self.unidirectionalStreams.remoteMaxStreams = Int(maxStreams) self.unidirectionalStreams.updateRemoteMaxStreams( server: self.isServer, @@ -4735,11 +4735,11 @@ extension QUICConnection { } else { if self.bidirectionalStreams.remoteMaxStreams >= maxStreams { log.notice( - "new MAX_STREAMS_BIDI \(maxStreams) doesn't advance current limit \(self.bidirectionalStreams.remoteMaxStreams)" + "New MAX_STREAMS_BIDI \(maxStreams) doesn't advance current limit \(self.bidirectionalStreams.remoteMaxStreams)" ) return true } - log.notice("bidirectional max streams now \(maxStreams)") + log.notice("Bidirectional max streams now \(maxStreams)") self.bidirectionalStreams.remoteMaxStreams = Int(maxStreams) self.bidirectionalStreams.updateRemoteMaxStreams( server: self.isServer, @@ -4802,7 +4802,7 @@ extension QUICConnection { close(with: .streamLimitError, "STREAMS_BLOCKED_BIDI exceeds 2**60") return false } - log.notice("streams blocked bidi: \(frame.limit)") + log.notice("Streams blocked bidi: \(frame.limit)") deliverNetworkProtocolEvent( flow: .allFlows, event: .init( @@ -4823,7 +4823,7 @@ extension QUICConnection { close(with: .streamLimitError, "STREAMS_BLOCKED_UNI exceeds 2**60") return false } - log.notice("streams blocked uni: \(frame.limit)") + log.notice("Streams blocked uni: \(frame.limit)") deliverNetworkProtocolEvent( flow: .allFlows, event: .init( @@ -4917,7 +4917,7 @@ extension QUICConnection { private func sendStopSending(stream: QUICStreamInstance) { guard let streamID = stream.streamID else { - log.notice("cannot send STOP_SENDING without stream ID") + log.notice("Cannot send STOP_SENDING without stream ID") return } // Note: Error can be 0 for stop sending; still send the frame @@ -4925,7 +4925,7 @@ extension QUICConnection { if let applicationErrorCode = stream.inboundApplicationError { errorCode = applicationErrorCode } - stream.log.notice("sending STOP_SENDING, error: \(errorCode)") + stream.log.notice("Sending STOP_SENDING, error: \(errorCode)") applicationPendingItems.addStreamStopSending(streamID: streamID.value, code: errorCode) } @@ -4937,7 +4937,7 @@ extension QUICConnection { private func sendResetStream(stream: QUICStreamInstance) { guard let streamID = stream.streamID else { - log.notice("cannot send RESET_STREAM without stream ID") + log.notice("Cannot send RESET_STREAM without stream ID") return } @@ -4954,7 +4954,7 @@ extension QUICConnection { code: errorCode, finalSize: stream.sendOffset ) - stream.log.notice("sending RESET_STREAM, error: \(errorCode)") + stream.log.notice("Sending RESET_STREAM, error: \(errorCode)") stream.resetSent = true stream.sendState.change(logIDString: stream.logPrefix, to: .resetSent) } @@ -5070,7 +5070,7 @@ extension QUICConnection { log.error("Failed to send version negotiation frame with error: \(error)") return } - log.info("sent version negotiation packet") + log.info("Sent version negotiation packet") } func sendRetry(path: QUICPath, packet: borrowing Packet) { @@ -5144,7 +5144,7 @@ extension QUICConnection { log.error("Failed to send retry frame with error: \(error)") return } - log.info("sent retry packet") + log.info("Sent retry packet") } } @@ -5169,12 +5169,12 @@ extension QUICConnection { isServer: isServer ) guard let streamID else { - log.error("out of streamIDs") + log.error("Out of streamIDs") return false } stream.resetStreamID(streamID: streamID) - log.debug("updating flow \(flowID.debugDescription) for key \(streamID)") + log.debug("Updating flow \(flowID.debugDescription) for key \(streamID)") knownFlows[streamID] = flowID if !stream.unidirectional { @@ -5197,12 +5197,12 @@ extension QUICConnection { let flowID = stream.identifier if stream.sendState == .invalid && stream.receiveState == .invalid { if !readyPendingStream(stream, flowID: flowID) { - log.error("could not ready pending stream") + log.error("Could not ready pending stream") } } else { guard stream.streamID != nil else { stream.log.error( - "stream for flow \(flowID) has no streamID" + "Stream for flow \(flowID) has no streamID" ) return } @@ -5326,13 +5326,13 @@ extension QUICConnection { isBidirectional: streamID.isBidirectional ) else { - Logger.proto.error("next inbound stream id is not valid") + Logger.proto.error("Next inbound stream id is not valid") return (created: false, checkZombie: streamIDCheck.checkZombie) } guard !inboundFlowLinkage.isDetached else { log.error( - "no inbound flow handler, cannot accept stream ID \(streamID)" + "No inbound flow handler, cannot accept stream ID \(streamID)" ) // Send STOP_SENDING (and RESET_STREAM for bidirectional streams) // so the peer knows we are refusing this stream. @@ -5362,7 +5362,7 @@ extension QUICConnection { if self.streamIDBlocked(streamID: streamID) { log.error( - "stream ID \(streamID) exceeded the maximum allowed" + "Stream ID \(streamID) exceeded the maximum allowed" ) close(with: .streamLimitError, "exceeded maximum stream ID") return (created: false, checkZombie: false) @@ -5397,7 +5397,7 @@ extension QUICConnection { deliverNewInboundFlowEvent(newStream.reference, flowMetadata: abstractMetadata) log.debug( - "set stream \(newStreamID.description) for flow \(newFlowIdentifier.debugDescription)" + "Set stream \(newStreamID.description) for flow \(newFlowIdentifier.debugDescription)" ) newStream.setupMaxStreamData( @@ -5414,15 +5414,15 @@ extension QUICConnection { stats.increment(.inboundUnidirectionalStreams) } if newStreamID == streamID { - log.info("creating inbound stream \(streamID)") + log.info("Creating inbound stream \(streamID)") } else { - log.info("creating inbound stream \(newStreamID) (out of order)") + log.info("Creating inbound stream \(newStreamID) (out of order)") } } // for newStreamID in stride // For now, at least protect from the overflow and add log to be able to diagnose this situation. guard let theNextStreamID = streamID.nextOfSameTypeAndInitiator() else { - log.error("inbound streams created, but out of future stream credits") + log.error("Inbound streams created, but out of future stream credits") // We've succeeded in creating the streams above, so return success. return (created: true, checkZombie: false) } @@ -5679,7 +5679,7 @@ extension QUICConnection { func acknowledgedResetStream(id: UInt64) { guard let stream = streamFromStreamID(id) else { - log.error("stream frame with invalid stream ID \(id)") + log.error("Stream frame with invalid stream ID \(id)") return } @@ -5980,7 +5980,7 @@ extension QUICConnection { // connection error. if frame.retirePriorToSequence > frame.sequence { log.error( - "received NEW_CONNECTION_ID frame on with retire prior to field larger than seq field" + "Received NEW_CONNECTION_ID frame on with retire prior to field larger than seq field" ) close(with: .protocolViolation, "NEW_CONNECTION_ID: invalid retire prior field") return false diff --git a/Sources/SwiftNetwork/QUIC/QUICConnectionID.swift b/Sources/SwiftNetwork/QUIC/QUICConnectionID.swift index 47d5d14..8077ac2 100644 --- a/Sources/SwiftNetwork/QUIC/QUICConnectionID.swift +++ b/Sources/SwiftNetwork/QUIC/QUICConnectionID.swift @@ -85,7 +85,7 @@ public struct QUICConnectionID: Sendable, Equatable, CustomStringConvertible { public init?(_ connectionID: [UInt8]) { guard connectionID.count <= QUICConnectionID.maximumSize else { let connectionIDCount = connectionID.count - Logger.proto.fault("invalid QUICConnectionID length \(connectionIDCount)") + Logger.proto.fault("Invalid QUICConnectionID length \(connectionIDCount)") return nil } actualLength = connectionID.count @@ -105,7 +105,7 @@ public struct QUICConnectionID: Sendable, Equatable, CustomStringConvertible { public init?(_ connectionID: Span) { guard connectionID.count <= QUICConnectionID.maximumSize else { let connectionIDCount = connectionID.count - Logger.proto.fault("invalid QUICConnectionID length \(connectionIDCount)") + Logger.proto.fault("Invalid QUICConnectionID length \(connectionIDCount)") return nil } actualLength = connectionID.count @@ -116,7 +116,7 @@ public struct QUICConnectionID: Sendable, Equatable, CustomStringConvertible { public init(_ size: Int) { var size = size if size > QUICConnectionID.maximumSize { - Logger.proto.fault("invalid QUICConnectionID length \(size)") + Logger.proto.fault("Invalid QUICConnectionID length \(size)") size = QUICConnectionID.maximumSize } if size != 0 && size < 4 { @@ -129,7 +129,7 @@ public struct QUICConnectionID: Sendable, Equatable, CustomStringConvertible { // Creates a QUICConnectionID from a buffer with a specific size. init?(_ buffer: [UInt8], size: Int) { guard size <= QUICConnectionID.maximumSize, buffer.count >= size else { - Logger.proto.fault("invalid QUICConnectionID length \(size)") + Logger.proto.fault("Invalid QUICConnectionID length \(size)") return nil } let cidBytes = Array(buffer[0.. Bool { guard let streamID = QUICStreamID(self.id) else { let idValue = self.id - Logger.proto.error("stream frame with invalid stream ID \(idValue)") + Logger.proto.error("Stream frame with invalid stream ID \(idValue)") return false } // An endpoint that receives a RESET_STREAM frame for a @@ -1123,7 +1123,7 @@ struct FrameResetStream: ~Copyable, QUICFrameProtocol { let created = connection.flow(for: flowID) else { Logger.proto.error( - "stream \(streamID.value) is not a QUICStreamInstance after createInboundStreams" + "Stream \(streamID.value) is not a QUICStreamInstance after createInboundStreams" ) return true } @@ -1255,14 +1255,14 @@ struct FrameStopSending: ~Copyable, QUICFrameProtocol { func process(connection: QUICConnection) -> Bool { guard let streamID = QUICStreamID(self.id) else { let idValue = self.id - Logger.proto.error("stream frame with invalid stream ID \(idValue)") + Logger.proto.error("Stream frame with invalid stream ID \(idValue)") return false } // An endpoint that receives a STOP_SENDING frame for a receive-only // stream MUST terminate the connection with error STREAM_STATE_ERROR. if streamID.isReceiveOnly(server: connection.isServer) { Logger.proto.error( - "received STOP_SENDING for receive only stream" + "Received STOP_SENDING for receive only stream" ) connection.close(with: .streamStateError, "STREAM frame on send-only stream") return false diff --git a/Sources/SwiftNetwork/QUIC/QUICStream.swift b/Sources/SwiftNetwork/QUIC/QUICStream.swift index ee5d45c..ac079b7 100644 --- a/Sources/SwiftNetwork/QUIC/QUICStream.swift +++ b/Sources/SwiftNetwork/QUIC/QUICStream.swift @@ -72,7 +72,7 @@ struct QUICStreamIDState: ~Copyable { pendingStartStreams.append(stream) stream.pendingStart = true let logContext = self.logContext - stream.log.debug("is pending \(logContext)") + stream.log.debug("Is pending \(logContext)") } mutating func removePending(_ stream: QUICStreamInstance) { @@ -88,7 +88,7 @@ struct QUICStreamIDState: ~Copyable { pendingStartStreams.remove(at: index) stream.pendingStart = false let logContext = self.logContext - stream.log.debug("is no longer pending \(logContext)") + stream.log.debug("Is no longer pending \(logContext)") } mutating func removeAllPending() { @@ -161,7 +161,7 @@ struct QUICStreamIDState: ~Copyable { return (valid: false, checkZombie: true) } else { connection.log.error( - "peer is attempting to open an invalid stream (\(streamID)); our role is \(isServer ? "server" : "client") (last \(logContext) \(largestOutboundStreamID?.description ?? "nil"))" + "Peer is attempting to open an invalid stream (\(streamID)); our role is \(isServer ? "server" : "client") (last \(logContext) \(largestOutboundStreamID?.description ?? "nil"))" ) connection.close(with: .streamStateError, "invalid stream ID") @@ -171,7 +171,7 @@ struct QUICStreamIDState: ~Copyable { if newStreamIDsAreBlocked(streamID) { connection.log.error( - "stream ID \(streamID) exceeded the maximum allowed" + "Stream ID \(streamID) exceeded the maximum allowed" ) connection.close(with: .streamLimitError, "exceeded maximum stream ID") @@ -183,7 +183,7 @@ struct QUICStreamIDState: ~Copyable { // already closed. if streamID < nextInboundStreamID { connection.log.info( - "not recreating closed stream (next \(logContext) \(nextInboundStreamID))" + "Not recreating closed stream (next \(logContext) \(nextInboundStreamID))" ) return (valid: false, checkZombie: true) } @@ -395,7 +395,7 @@ struct QUICStreamList: ~Copyable { } list.remove(at: index) stream.listMembership.remove(listType) - stream.log.debug("removed from \(name)") + stream.log.debug("Removed from \(name)") } mutating func removeAll(connection: QUICConnection) { @@ -624,9 +624,9 @@ public final class QUICStreamInstance: MultiplexedStreamFlow, deinit { if let streamID = streamID { - log.debug("deallocating unassigned stream \(streamID.value)") + log.debug("Deallocating unassigned stream \(streamID.value)") } else { - log.debug("deallocating unassigned stream") + log.debug("Deallocating unassigned stream") } reassemblyQueue.dequeueAll() // If handleStreamClose has already been called just return @@ -704,7 +704,7 @@ public final class QUICStreamInstance: MultiplexedStreamFlow, // have enough space to take the stream data if frame.length > flowControlState.maximumUnreadInboundBytesAllowed { log.error( - "not enough receive buffer space \(frame.length) > \(flowControlState.maximumUnreadInboundBytesAllowed)" + "Not enough receive buffer space \(frame.length) > \(flowControlState.maximumUnreadInboundBytesAllowed)" ) frame.frame.finalize(success: false) return false @@ -788,7 +788,7 @@ public final class QUICStreamInstance: MultiplexedStreamFlow, } if newOffset > reassemblyQueue.finOffset { log.error( - "bytes received \(newOffset) > fin offset \(reassemblyQueue.finOffset)" + "Bytes received \(newOffset) > fin offset \(reassemblyQueue.finOffset)" ) connection.close(with: .internalError, "bytes received larger than FIN offset") return false @@ -915,7 +915,7 @@ public final class QUICStreamInstance: MultiplexedStreamFlow, let totalLength = reassemblyQueue.availableToDequeue log.datapath("total available reassembled data \(totalLength)") guard totalLength >= 0 else { - log.error("reassembled data length cannot be negative") + log.error("Reassembled data length cannot be negative") return nil } if totalLength == 0 { @@ -934,7 +934,7 @@ public final class QUICStreamInstance: MultiplexedStreamFlow, // This is a ReassemblyQueue bug, hopefully retransmission will recover // Therefore `deliveredInboundBytes` is called below, so all the accounting is // kept correct. - log.error("reassembled dequeued data length > available length, dropping data") + log.error("Reassembled dequeued data length > available length, dropping data") break } @@ -967,7 +967,7 @@ public final class QUICStreamInstance: MultiplexedStreamFlow, if writtenCount < totalLength { // This is a ReassemblyQueue bug, but should be recoverable log.error( - "reassembled dequeued data length \(writtenCount) < available length \(totalLength)" + "Reassembled dequeued data length \(writtenCount) < available length \(totalLength)" ) } @@ -1054,7 +1054,7 @@ public final class QUICStreamInstance: MultiplexedStreamFlow, return } log.notice( - "reached unidirectional stream limit (STREAMS_BLOCKED): \(connection.unidirectionalStreams.remoteMaxStreams)" + "Reached unidirectional stream limit (STREAMS_BLOCKED): \(connection.unidirectionalStreams.remoteMaxStreams)" ) connection.unidirectionalStreams.previousRemoteMaxStreams = connection.unidirectionalStreams.remoteMaxStreams @@ -1070,7 +1070,7 @@ public final class QUICStreamInstance: MultiplexedStreamFlow, return } log.notice( - "reached bidirectional stream limit (STREAMS_BLOCKED): \(connection.bidirectionalStreams.remoteMaxStreams)" + "Reached bidirectional stream limit (STREAMS_BLOCKED): \(connection.bidirectionalStreams.remoteMaxStreams)" ) connection.bidirectionalStreams.previousRemoteMaxStreams = connection.bidirectionalStreams.remoteMaxStreams diff --git a/Sources/SwiftNetwork/QUIC/QUICStreamZombies.swift b/Sources/SwiftNetwork/QUIC/QUICStreamZombies.swift index e659f15..c0bc688 100644 --- a/Sources/SwiftNetwork/QUIC/QUICStreamZombies.swift +++ b/Sources/SwiftNetwork/QUIC/QUICStreamZombies.swift @@ -146,7 +146,7 @@ struct QUICStreamZombieList { return } connection.log.debug( - "received final size of \(finalSize) (previous received size \(lastSize)" + "Received final size of \(finalSize) (previous received size \(lastSize)" ) let newLastOffset = finalSize == 0 ? 0 : finalSize - 1 @@ -170,7 +170,7 @@ struct QUICStreamZombieList { ) else { connection.log.error( - "final size invariants violated (final size \(finalSize))" + "Final size invariants violated (final size \(finalSize))" ) return } diff --git a/Sources/SwiftNetwork/QUIC/QUICUtilities.swift b/Sources/SwiftNetwork/QUIC/QUICUtilities.swift index e4503bc..8677424 100644 --- a/Sources/SwiftNetwork/QUIC/QUICUtilities.swift +++ b/Sources/SwiftNetwork/QUIC/QUICUtilities.swift @@ -63,7 +63,7 @@ public struct QUICConnectionUtilities { shortHeaderDestinationCIDLength: Int? ) -> QUICRoutingHeader? { guard buffer.count >= Constants.minimumPacketSize else { - Logger.proto.error("buffer length < minimum packet size, len=\(buffer.count)") + Logger.proto.error("Buffer length < minimum packet size, len=\(buffer.count)") return nil } diff --git a/Sources/SwiftNetwork/QUIC/RTT.swift b/Sources/SwiftNetwork/QUIC/RTT.swift index 95aedc8..48a816d 100644 --- a/Sources/SwiftNetwork/QUIC/RTT.swift +++ b/Sources/SwiftNetwork/QUIC/RTT.swift @@ -57,7 +57,7 @@ struct RTT: ~Copyable, PrefixedLoggable { } set { _remoteMaxAckDelay = newValue - log.debug("new remoteMaxAckDelay: \(_remoteMaxAckDelay)") + log.debug("New remoteMaxAckDelay: \(_remoteMaxAckDelay)") } } diff --git a/Sources/SwiftNetwork/QUIC/ReassemblyQueue.swift b/Sources/SwiftNetwork/QUIC/ReassemblyQueue.swift index 56210a3..8b6d085 100644 --- a/Sources/SwiftNetwork/QUIC/ReassemblyQueue.swift +++ b/Sources/SwiftNetwork/QUIC/ReassemblyQueue.swift @@ -262,7 +262,7 @@ struct ReassemblyQueue: ~Copyable { if _slowPath(size < oldSize) { traceDump() - log.fault("reassq length went backwards \(size) < \(oldSize)") + log.fault("Reassq length went backwards \(size) < \(oldSize)") return 0 } return size - oldSize @@ -286,17 +286,17 @@ struct ReassemblyQueue: ~Copyable { "advanced \(dequeueItem.length), current offset \(currentOffset)" ) if headOfLineBlocked { - log.debug("no longer head of line blocked") + log.debug("No longer head of line blocked") } headOfLineBlocked = false return dequeueItem } else if _slowPath(currentOffset > firstItemOffset) { traceDump() - log.fault("current offset \(currentOffset) > \(firstItemOffset)") + log.fault("Current offset \(currentOffset) > \(firstItemOffset)") return nil } else { log.debug( - "head of line blocked, bytes missing: [\(currentOffset),\(firstItemOffset)) (\(firstItemOffset - currentOffset) bytes)" + "Head of line blocked, bytes missing: [\(currentOffset),\(firstItemOffset)) (\(firstItemOffset - currentOffset) bytes)" ) headOfLineBlocked = true traceDump() diff --git a/Sources/SwiftNetwork/QUIC/StatelessResetToken.swift b/Sources/SwiftNetwork/QUIC/StatelessResetToken.swift index aa5d6d0..f55052a 100644 --- a/Sources/SwiftNetwork/QUIC/StatelessResetToken.swift +++ b/Sources/SwiftNetwork/QUIC/StatelessResetToken.swift @@ -38,7 +38,7 @@ public struct QUICStatelessResetToken: Equatable, Sendable, CustomStringConverti public init?(_ token: [UInt8]) { guard token.count == QUICStatelessResetToken.size else { - Logger.proto.fault("invalid Stateless Reset Token") + Logger.proto.fault("Invalid Stateless Reset Token") return nil } _token = TokenStorage(tokenSpan: token.span) @@ -46,7 +46,7 @@ public struct QUICStatelessResetToken: Equatable, Sendable, CustomStringConverti public init?(_ token: Span) { guard token.count == QUICStatelessResetToken.size else { - Logger.proto.fault("invalid Stateless Reset Token") + Logger.proto.fault("Invalid Stateless Reset Token") return nil } _token = TokenStorage(tokenSpan: token) diff --git a/Sources/SwiftNetwork/QUIC/Timer.swift b/Sources/SwiftNetwork/QUIC/Timer.swift index e89b237..e5547fd 100644 --- a/Sources/SwiftNetwork/QUIC/Timer.swift +++ b/Sources/SwiftNetwork/QUIC/Timer.swift @@ -120,7 +120,7 @@ final class Timer: PrefixedLoggable { func stop(final: Bool = true) { if !timerCancelled { - log.debug("stopping timer") + log.debug("Stopping timer") timerCancelled = true reference?.unscheduleWakeup() } @@ -163,7 +163,7 @@ final class Timer: PrefixedLoggable { } guard let earliestDeadline else { - log.debug("no more timers to run") + log.debug("No more timers to run") stop(final: false) return } @@ -231,7 +231,7 @@ final class Timer: PrefixedLoggable { public func timerFired(timeNow: NetworkClock.Instant = .now) { if _slowPath(timerCancelled) { - log.fault("timer fired after it was cancelled") + log.fault("Timer fired after it was cancelled") return } // Due to timer leeway, we might actually be running a bit early, so @@ -270,11 +270,11 @@ final class Timer: PrefixedLoggable { let entryCount = entries.count for i in 0.. TransportParameters { var parameters = TransportParameters(logPrefixer: logPrefixer) guard buffer.count >= 0 && buffer.count < UInt16.max else { - parameters.log.error("invalid TP size \(buffer.count)") + parameters.log.error("Invalid TP size \(buffer.count)") throw QUICError.transportParametersDecode(TransportParameterDecodeErrors.invalidSize) } - parameters.log.debug("deserializing transport parameters (size \(buffer.count))") + parameters.log.debug("Deserializing transport parameters (size \(buffer.count))") var maxAckDelay: UInt64? = nil var minAckDelay: UInt64? = nil @@ -769,7 +769,7 @@ public struct TransportParameters: PrefixedLoggable { } } guard buffer.count >= parameterLength && parameterLength < UInt16.max else { - parameters.log.error("invalid length \(parameterLength)") + parameters.log.error("Invalid length \(parameterLength)") throw QUICError.transportParametersDecode( TransportParameterDecodeErrors.invalidSize ) diff --git a/Tests/SwiftNetworkTests/SwiftNetworkInterfaceTests.swift b/Tests/SwiftNetworkTests/SwiftNetworkInterfaceTests.swift index e3253eb..119c88f 100644 --- a/Tests/SwiftNetworkTests/SwiftNetworkInterfaceTests.swift +++ b/Tests/SwiftNetworkTests/SwiftNetworkInterfaceTests.swift @@ -72,7 +72,7 @@ final class SwiftNetworkInterfaceTests: NetTestCase { let wastedSockFd = socket(AF_INET, Int32(SOCK_DGRAM.rawValue), 0) #endif if wastedSockFd < 0 { - Logger.proto.info("successfully opened too many sockets") + Logger.proto.info("Successfully opened too many sockets") socketsExhausted = true break }