Skip to content

Commit 903aa50

Browse files
committed
Merge branch '3.7-dev' into 3.8-dev
2 parents 1f998c3 + b305bc9 commit 903aa50

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
@@ -536,7 +536,7 @@ type implementation. To input a set into Gremlin-Go, a custom struct which imple
536536
will be serialized as a set. `gremlingo.NewSimpleSet` is a basic implementation of a set that is provided by Gremlin-Go
537537
that can be used to fulfill the `gremlingo.Set` interface if desired.
538538
539-
* Go does not support ordered maps natively as the built-in `map` type does not guarantee iteration order. Traversal
539+
* Go does not support ordered maps natively as the built-in `map` type does not guarantee iteration order. Traversal
540540
results which contain maps may not preserve original ordering when deserialized into Go's native map types.
541541
542542
[[gremlin-go-examples]]
@@ -1587,6 +1587,56 @@ can be passed in the constructor of a new `Client` or `DriverRemoteConnection` :
15871587
|options.pongTimeout |Number |Timeout of pong response in ms after sending a ping. |30000
15881588
|=========================================================
15891589
1590+
[[gremlin-javascript-logging]]
1591+
=== Logging
1592+
1593+
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`:
1594+
1595+
[source,javascript]
1596+
----
1597+
// Using DriverRemoteConnection
1598+
const dc = new DriverRemoteConnection('ws://localhost:8182/gremlin');
1599+
1600+
dc.addListener('log', (message) => {
1601+
console.log('[Gremlin Log]', message);
1602+
});
1603+
1604+
dc.addListener('socketError', (err) => {
1605+
console.error('[Gremlin Error]', err);
1606+
});
1607+
1608+
dc.addListener('close', (code, message) => {
1609+
console.warn('[Gremlin Close]', code, message);
1610+
});
1611+
1612+
const g = traversal().withRemote(dc);
1613+
1614+
// Using Client
1615+
const client = new Client('ws://localhost:8182/gremlin', { traversalSource: 'g' });
1616+
1617+
client.addListener('log', (message) => {
1618+
console.log('[Gremlin Log]', message);
1619+
});
1620+
1621+
client.addListener('socketError', (err) => {
1622+
console.error('[Gremlin Error]', err);
1623+
});
1624+
1625+
client.addListener('close', (code, message) => {
1626+
console.warn('[Gremlin Close]', code, message);
1627+
});
1628+
1629+
await client.open();
1630+
----
1631+
1632+
Available events:
1633+
1634+
* `log` - General connection logs (open, ping, pong, close, errors)
1635+
* `socketError` - WebSocket errors
1636+
* `close` - Connection close with status code and message
1637+
1638+
To remove a listener, use `removeListener(event, handler)` with the same handler reference.
1639+
15901640
[[gremlin-javascript-strategies]]
15911641
=== Traversal Strategies
15921642

0 commit comments

Comments
 (0)