Skip to content

Commit

Permalink
Update logging attributes (#78)
Browse files Browse the repository at this point in the history
* Update logging attributes

* Move logger error into metadata

* Received reserved opcode metadata change
  • Loading branch information
adam-fowler authored Sep 11, 2024
1 parent 1505910 commit 3b09485
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Sources/HummingbirdWSCore/WebSocketInboundStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public final class WebSocketInboundStream: AsyncSequence, Sendable {
return .init(from: frame)
default:
// if we receive a reserved opcode we should fail the connection
self.handler.logger.trace("Received reserved opcode", metadata: ["opcode": .stringConvertible(frame.opcode)])
self.handler.logger.trace("Received reserved opcode", metadata: ["hb.ws.opcode": .stringConvertible(frame.opcode)])
throw WebSocketHandler.InternalError.close(.protocolError)
}
} catch {
Expand Down
10 changes: 5 additions & 5 deletions Sources/HummingbirdWebSocket/WebSocketChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public struct HTTP1WebSocketUpgradeChannel: ServerChildChannel, HTTPChannelHandl
handler: handler
)
} catch {
logger.debug("WebSocket handler error", metadata: ["error": "\(error)"])
logger.debug("WebSocket handler error", metadata: ["error.type": "\(error)"])
}
})
}
Expand Down Expand Up @@ -137,7 +137,7 @@ public struct HTTP1WebSocketUpgradeChannel: ServerChildChannel, HTTPChannelHandl
handler: handler
)
} catch {
logger.debug("WebSocket handler error", metadata: ["error": "\(error)"])
logger.debug("WebSocket handler error", metadata: ["error.type": "\(error)"])
}
})
}
Expand Down Expand Up @@ -218,7 +218,7 @@ public struct HTTP1WebSocketUpgradeChannel: ServerChildChannel, HTTPChannelHandl
await handler(asyncChannel, logger)
}
} catch {
logger.error("Error handling upgrade result: \(error)")
logger.error("Error handling upgrade result", metadata: ["error.type": .string("\(error)")])
}
}

Expand Down Expand Up @@ -265,7 +265,7 @@ public struct HTTP1WebSocketUpgradeChannel: ServerChildChannel, HTTPChannelHandl
if clientHeaders.count > 0 {
logger.trace(
"Extensions requested",
metadata: ["hb_extensions": .string(clientHeaders.map(\.name).joined(separator: ","))]
metadata: ["hb.ws.extensions": .string(clientHeaders.map(\.name).joined(separator: ","))]
)
}
let extensionResponseHeaders = extensionBuilders.compactMap { $0.serverResponseHeader(to: clientHeaders) }
Expand All @@ -276,7 +276,7 @@ public struct HTTP1WebSocketUpgradeChannel: ServerChildChannel, HTTPChannelHandl
if extensions.count > 0 {
logger.debug(
"Enabled extensions",
metadata: ["hb_extensions": .string(extensions.map(\.name).joined(separator: ","))]
metadata: ["hb.ws.extensions": .string(extensions.map(\.name).joined(separator: ","))]
)
}
return (responseHeaders, extensions)
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdWebSocket/WebSocketRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ extension HTTP1WebSocketUpgradeChannel {
handler: webSocketHandler.handler
)
} catch {
logger.debug("WebSocket handler error", metadata: ["error": "\(error)"])
logger.debug("WebSocket handler error", metadata: ["error.type": "\(error)"])
}
}
} else {
Expand Down

0 comments on commit 3b09485

Please sign in to comment.