mgo怎么显示查询语句

mgo 设置了debug . 为true

有没有显示直接查询语句的api

mgo.SetDebug(true)

阅读 8.5k
2 个回答

10个月后我谷歌居然找到了自己提的问题。。。

友情回答一下把

    // 实现 mongo.Logger 的接口
    type MongoLog struct {
    }
    
    func (MongoLog)Output(calldepth int, s string) error {
        log.SetFlags(log.Lshortfile)
        return log.Output(calldepth,s)
    }
    mgo.SetDebug(true)  // 设置DEBUG模式
    mgo.SetLogger(new(MongoLog)) // 设置日志. 

用 tcpdump 监听 MySQL 服务器 ip 和端口

推荐问题