Weihao's Blog

Debug MongoDB with Golang mongo-dirve

cmdMonitor := &event.CommandMonitor{
		Started: func(_ context.Context, evt *event.CommandStartedEvent) {
			log.Printf("Command started: %v\n", evt.Command)
		},
	}

	option := options.Client().ApplyURI(connectionURI).SetMonitor(cmdMonitor)