wrapWs on the plugin instance to add lifecycle logs for WebSocket routes:
WS, the route path, duration, and optional wsId in context.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
The canonical Logixlysia documentation lives at logixlysia.vercel.app. This mirror exists to power the AI assistant.
Log WebSocket open, message, and close events
wrapWs on the plugin instance to add lifecycle logs for WebSocket routes:
import { Elysia } from 'elysia'
import logixlysia from 'logixlysia'
const plugin = logixlysia({
config: {
service: 'chat'
}
})
const app = new Elysia()
.use(plugin)
.ws(
'/chat',
plugin.wrapWs({
open(ws) {
ws.send('connected')
},
message(ws, message) {
ws.send(message)
},
close(ws) {
console.log('bye', ws.id)
}
})
)
WS, the route path, duration, and optional wsId in context.
.ws(
'/chat',
plugin.wrapWs({
message(ws, payload) {
ws.data.store.logger.mergeContext(ws, { lastPayloadType: typeof payload })
}
})
)
logixlysia({
config: {
disableWebSocketLogging: true
}
})
Was this page helpful?