本文整理汇总了Golang中github.com/atnet/gof.App.Log方法的典型用法代码示例。如果您正苦于以下问题:Golang App.Log方法的具体用法?Golang App.Log怎么用?Golang App.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/atnet/gof.App
的用法示例。
在下文中一共展示了App.Log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RunWeb
// 运行网页
func RunWeb(app gof.App, port int, debug, trace bool) {
if debug {
fmt.Println("[Started]:Web server (with debug) running on port [" +
strconv.Itoa(port) + "]:")
infrastructure.DebugMode = true
} else {
fmt.Println("[Started]:Web server running on port [" + strconv.Itoa(port) + "]:")
}
//socket client
time.Sleep(time.Second * 2) //等待启动Socket
API_DOMAIN = app.Config().GetString(variable.ApiDomain)
goclient.Configure("tcp", app.Config().GetString(variable.ClientSocketServer), app)
var in = getInterceptor(app)
//注册路由
RegisterRoutes(app)
//启动服务
err := http.ListenAndServe(":"+strconv.Itoa(port), in)
if err != nil {
app.Log().Fatalln("ListenAndServer ", err)
}
}
示例2: RunRestApi
func RunRestApi(app gof.App, port int) {
fmt.Println("[ Go2o][ API][ Booted] - Api server running on port " + strconv.Itoa(port))
//socket client
time.Sleep(time.Second * 2) //等待启动Socket
API_DOMAIN = app.Config().GetString(variable.ApiDomain)
goclient.Configure("tcp", app.Config().GetString(variable.ClientSocketServer), app)
var in *web.Interceptor = web.NewInterceptor(app, func(ctx *web.Context) {
host := ctx.Request.URL.Host
// todo: path compare
if API_HOST_CHK && host != API_DOMAIN {
http.Error(ctx.Response, "no such file", http.StatusNotFound)
return
}
api.Handle(ctx)
})
//启动服务
err := http.ListenAndServe(":"+strconv.Itoa(port), in)
if err != nil {
app.Log().Fatalln("ListenAndServer ", err)
}
}
示例3: RunWeb
// 运行网页
func RunWeb(app gof.App, port int, debug, trace bool) {
if debug {
fmt.Println("[ Go2o][ Web][ Booted] - Web server (with debug) running on port " +
strconv.Itoa(port))
infrastructure.DebugMode = true
} else {
fmt.Println("[ Go2o][ Web][ Booted] - Web server running on port " + strconv.Itoa(port))
}
//socket client
time.Sleep(time.Second * 2) //等待启动Socket
API_DOMAIN = app.Config().GetString(variable.ApiDomain)
var in = getInterceptor(app)
//启动服务
err := http.ListenAndServe(":"+strconv.Itoa(port), in)
if err != nil {
app.Log().Fatalln("ListenAndServer ", err)
}
}
示例4: setupOrder
func (this *Shopping) setupOrder(ctx gof.App, v *shopping.ValueOrder,
conf *partner.SaleConf, t time.Time, f func(error)) {
var err error
order := this.CreateOrder(v, nil)
dur := time.Duration(t.Unix()-v.CreateTime) * time.Second
if v.PaymentOpt == enum.PAY_ONLINE {
if v.IsPaid == 0 && dur > time.Hour*order_timeout_hour {
order.Cancel("超时未付款,系统取消")
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Payment Timeout\n", v.OrderNo)
}
}
} else if v.PaymentOpt == enum.PAY_OFFLINE {
switch v.Status + 1 {
case enum.ORDER_CONFIRMED:
if dur > time.Minute*order_confirm_minute {
err = order.Confirm()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Confirm \n", v.OrderNo)
}
shop, err := this.SmartChoiceShop(v.DeliverAddress)
if err != nil {
log.Println(err)
order.Suspend("智能分配门店失败!原因:" + err.Error())
} else {
sv := shop.GetValue()
order.SetShop(shop.GetDomainId())
order.AppendLog(enum.ORDER_LOG_SETUP, false, fmt.Sprintf(
"自动分配门店:%s,电话:%s", sv.Name, sv.Phone))
}
}
case enum.ORDER_PROCESSING:
if dur > time.Minute*order_process_minute {
err = order.Process()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Processing \n", v.OrderNo)
}
}
case enum.ORDER_SENDING:
if dur > time.Minute*order_sending_minute {
err = order.Deliver()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Sending \n", v.OrderNo)
}
}
case enum.ORDER_RECEIVED:
if dur > time.Hour*order_receive_hour {
err = order.SignReceived()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Received \n", v.OrderNo)
}
}
case enum.ORDER_COMPLETED:
if dur > time.Hour*order_complete_hour {
err = order.Complete()
if ctx.Debug() {
ctx.Log().Printf("[ AUTO][OrderSetup]:%s - Complete \n", v.OrderNo)
}
}
}
}
if err != nil {
f(err)
}
}