Example #1
0
// 记录慢查询日志
func (this *DB) errorSqlLog(sql string, err error) {
	msg := time.Now().Format("2006-01-02 15:04:05") + " -- " + sql + "\n" + fmt.Sprintf("%v", err)
	if ok, err := util.WriteLog("error_sql.log", msg); !ok {
		log.Print(err)
	}
}
Example #2
0
// 记录慢查询日志
func (this *DB) slowQueryLog(sql string, queryTime int64) {
	msg := "Time: " + fmt.Sprintf("%s", queryTime) + " -- " + time.Now().Format("2006-01-02 15:04:05") + " -- " + sql + "\n"
	if ok, err := util.WriteLog("slow_query.log", msg); !ok {
		log.Print(err)
	}
}