Skip to content

Commit 5a0c1c0

Browse files
committed
Merge branch '3.8-dev'
2 parents 2d81a9a + 903aa50 commit 5a0c1c0

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

docs/src/reference/gremlin-variants.asciidoc

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ type implementation. To input a set into Gremlin-Go, a custom struct which imple
538538
will be serialized as a set. `gremlingo.NewSimpleSet` is a basic implementation of a set that is provided by Gremlin-Go
539539
that can be used to fulfill the `gremlingo.Set` interface if desired.
540540
541-
* Go does not support ordered maps natively as the built-in `map` type does not guarantee iteration order. Traversal
541+
* Go does not support ordered maps natively as the built-in `map` type does not guarantee iteration order. Traversal
542542
results which contain maps may not preserve original ordering when deserialized into Go's native map types.
543543
544544
[[gremlin-go-examples]]
@@ -1597,6 +1597,56 @@ can be passed in the constructor of a new `Client` or `DriverRemoteConnection` :
15971597
|options.pongTimeout |Number |Timeout of pong response in ms after sending a ping. |30000
15981598
|=========================================================
15991599
1600+
[[gremlin-javascript-logging]]
1601+
=== Logging
1602+
1603+
The Gremlin-JavaScript driver emits connection events for logging and monitoring, but these events are silently ignored unless a listener is attached. Use the `addListener()` method to subscribe to events after creating a `DriverRemoteConnection` or `Client`:
1604+
1605+
[source,javascript]
1606+
----
1607+
// Using DriverRemoteConnection
1608+
const dc = new DriverRemoteConnection('ws://localhost:8182/gremlin');
1609+
1610+
dc.addListener('log', (message) => {
1611+
console.log('[Gremlin Log]', message);
1612+
});
1613+
1614+
dc.addListener('socketError', (err) => {
1615+
console.error('[Gremlin Error]', err);
1616+
});
1617+
1618+
dc.addListener('close', (code, message) => {
1619+
console.warn('[Gremlin Close]', code, message);
1620+
});
1621+
1622+
const g = traversal().withRemote(dc);
1623+
1624+
// Using Client
1625+
const client = new Client('ws://localhost:8182/gremlin', { traversalSource: 'g' });
1626+
1627+
client.addListener('log', (message) => {
1628+
console.log('[Gremlin Log]', message);
1629+
});
1630+
1631+
client.addListener('socketError', (err) => {
1632+
console.error('[Gremlin Error]', err);
1633+
});
1634+
1635+
client.addListener('close', (code, message) => {
1636+
console.warn('[Gremlin Close]', code, message);
1637+
});
1638+
1639+
await client.open();
1640+
----
1641+
1642+
Available events:
1643+
1644+
* `log` - General connection logs (open, ping, pong, close, errors)
1645+
* `socketError` - WebSocket errors
1646+
* `close` - Connection close with status code and message
1647+
1648+
To remove a listener, use `removeListener(event, handler)` with the same handler reference.
1649+
16001650
[[gremlin-javascript-strategies]]
16011651
=== Traversal Strategies
16021652

0 commit comments

Comments
 (0)