func main() { beego.SetLogger("file", `{"filename":"logs/beego_bootstrap_api.log"}`) orm.RunCommand() if beego.BConfig.RunMode == "dev" { orm.Debug = true file, _ := os.OpenFile("logs/orm.log", os.O_APPEND|os.O_WRONLY, 0600) orm.DebugLog = orm.NewLog(file) } beego.Run() }
func (bar *Bar) QueryAddBars(barId int64) ([]Bar, error) { o := orm.NewOrm() var data []Bar _, err := o.QueryTable("bar").Filter("BarId__gt", barId).Limit(10).All(&data) if err != nil { fmt.Println(err) } var w io.Writer = os.Stdout orm.DebugLog = orm.NewLog(w) return data, err }