作者 陈志颖

feat:添加日志下载

  1 +2020/11/22 20:04:49.106 [I] [???:0] http server Running on http://:8082
  2 +2020/11/22 20:16:14.979 [I] [???:0] http server Running on http://:8082
  3 +2020/11/22 20:16:34.647 [D] [server.go:1925] | ::1| 404 | 1.616744ms| nomatch| GET  /logs
  4 +2020/11/22 20:16:35.142 [D] [server.go:1925] | ::1| 404 | 432.829µs| nomatch| GET  /favicon.ico
  5 +2020/11/22 20:16:39.116 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./log.1606047399115973000
  6 + Auth=
  7 + BodyData:{}
  8 +2020/11/22 20:16:39.116 [D] [server.go:2843] <====Send RequestId:GET./log.1606047399115973000 BodyData:null
  9 +2020/11/22 20:16:39.116 [D] [server.go:1925] | ::1| 200 | 4.493459ms| match| GET  /log r:/log
  10 +2020/11/22 20:17:28.006 [D] [server.go:1925] | ::1| 404 | 427.795µs| nomatch| GET  /logs
  11 +2020/11/22 20:17:34.775 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./log.1606047454775197000
  12 + Auth=
  13 + BodyData:{}
  14 +2020/11/22 20:17:34.775 [D] [server.go:2843] <====Send RequestId:GET./log.1606047454775197000 BodyData:null
  15 +2020/11/22 20:17:34.776 [D] [server.go:1925] | ::1| 200 | 831.181µs| match| GET  /log r:/log
@@ -38,6 +38,7 @@ func main() { @@ -38,6 +38,7 @@ func main() {
38 38
39 // excel文件路径映射 39 // excel文件路径映射
40 beego.SetStaticPath("/download", "download") 40 beego.SetStaticPath("/download", "download")
  41 + beego.SetStaticPath("/logs", "log")
41 42
42 beego.Run() 43 beego.Run()
43 } 44 }
@@ -915,7 +915,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -915,7 +915,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
915 915
916 // 计算倒计时 916 // 计算倒计时
917 var t1 = time.Now().Local() 917 var t1 = time.Now().Local()
918 - var t2 = activityFound.Deadline 918 + var t2 = activityFound.Deadline.Local()
919 updateExchangeCashActivityCommand.CountDown = int64(math.Ceil(t2.Sub(t1).Hours() / 24)) 919 updateExchangeCashActivityCommand.CountDown = int64(math.Ceil(t2.Sub(t1).Hours() / 24))
920 920
921 // 倒计时结束处理 921 // 倒计时结束处理
@@ -9,7 +9,7 @@ var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com @@ -9,7 +9,7 @@ var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com
9 var MMM_OPEN_API_SERVICE_HOST = "http://mmm-open-api-dev.fjmaimaimai.com" 9 var MMM_OPEN_API_SERVICE_HOST = "http://mmm-open-api-dev.fjmaimaimai.com"
10 10
11 //var LOG_LEVEL = "debug" 11 //var LOG_LEVEL = "debug"
12 -var LOG_File = "app.log" 12 +var LOG_File = "logs/app.log"
13 13
14 func init() { 14 func init() {
15 if os.Getenv("LOG_LEVEL") != "" { 15 if os.Getenv("LOG_LEVEL") != "" {
@@ -520,6 +520,10 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -520,6 +520,10 @@ func (controller *SuMoneyController) ImportExchangeList () {
520 return 520 return
521 } 521 }
522 522
  523 +func (controller *SuMoneyController) LogFile() {
  524 + controller.Ctx.Output.Download("logs/app.log","app.log")
  525 +}
  526 +
523 // 导出素币兑换清单,选择导出(ids),增加导出失败信息 527 // 导出素币兑换清单,选择导出(ids),增加导出失败信息
524 func (controller *SuMoneyController) ExportExchangeList() { 528 func (controller *SuMoneyController) ExportExchangeList() {
525 cashPoolService := service.NewCashPoolService(nil) 529 cashPoolService := service.NewCashPoolService(nil)
@@ -38,4 +38,6 @@ func init() { @@ -38,4 +38,6 @@ func init() {
38 beego.Router("/cash-pool/activity/exchange-list/import", &controllers.SuMoneyController{}, "Post:ImportExchangeList") // 导入素币兑换清单 38 beego.Router("/cash-pool/activity/exchange-list/import", &controllers.SuMoneyController{}, "Post:ImportExchangeList") // 导入素币兑换清单
39 beego.Router("/cash-pool/activity/exchange-list/export", &controllers.SuMoneyController{}, "Post:ExportExchangeList") // 导出素币兑换清单 39 beego.Router("/cash-pool/activity/exchange-list/export", &controllers.SuMoneyController{}, "Post:ExportExchangeList") // 导出素币兑换清单
40 beego.Router("/cash-pool/activity/exchange-list/ranking", &controllers.SuMoneyController{}, "Post:ExchangeCashListRanking") // 兑换素币清单排行榜 40 beego.Router("/cash-pool/activity/exchange-list/ranking", &controllers.SuMoneyController{}, "Post:ExchangeCashListRanking") // 兑换素币清单排行榜
  41 +
  42 + beego.Router("/log", &controllers.SuMoneyController{}, "Get:LogFile") // 系统日志
41 } 43 }