i use node.js and node-mongodb-native driver, with connection pooling. is there any way to enable debug for see what's happening, how many connections are active and when a connection is opened or closed?
i would like to see something like:
* connection xxx opened on host:port * connection yyy opened on host:port * connection xxx closed
Node. js includes a command-line debugging utility. The Node. js debugger client is not a full-featured debugger, but simple stepping and inspection are possible.
A minimal CLI debugger is available with node inspect myscript. js . Several commercial and open source tools can also connect to the Node.
debug
.const client = new MongoClient('mongodb://127.0.0.1:27017/', {
useUnifiedTopology: true,
loggerLevel: 'debug',
// logger: (message, context) => console.dir(context),
})
// connection pool monitoring
client.on('connectionPoolCreated', event => console.dir(event))
client.on('connectionPoolClosed', event => console.dir(event))
client.on('connectionCreated', event => console.dir(event))
client.on('connectionReady', event => console.dir(event))
client.on('connectionClosed', event => console.dir(event))
client.on('connectionCheckOutStarted', event => console.dir(event))
client.on('connectionCheckOutFailed', event => console.dir(event))
client.on('connectionCheckedOut', event => console.dir(event))
client.on('connectionCheckedIn', event => console.dir(event))
client.on('connectionPoolCleared', event => console.dir(event))
// topology monitoring
client.on('serverDescriptionChanged', event => console.dir(event))
client.on('serverHeartbeatStarted', event => console.dir(event))
client.on('serverHeartbeatSucceeded', event => console.dir(event))
client.on('serverHeartbeatFailed', event => console.dir(event))
client.on('serverOpening', event => console.dir(event))
client.on('serverClosed', event => console.dir(event))
client.on('topologyOpening', event => console.dir(event))
client.on('topologyClosed', event => console.dir(event))
client.on('topologyDescriptionChanged', event => console.dir(event))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With