Commit 35c0874e0541be532c809c7e5731e497edba1167
1 parent
8b9ba965
Exists in
master
and in
1 other branch
refactor♻️:项目目录重构
Showing
7 changed files
with
83 additions
and
49 deletions
Show diff stats
| @@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
| 1 | +package zconst |
| @@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
| 1 | +package zlog | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "apigame/util/util-lx/lxalilog" | ||
| 5 | + "fmt" | ||
| 6 | + "github.com/astaxie/beego" | ||
| 7 | + lalilog "github.com/lixu-any/go-tools/ali/log" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func InitAliLog(appName string) { | ||
| 11 | + | ||
| 12 | + //初始化阿里云日志 | ||
| 13 | + logm, _ := beego.AppConfig.GetSection("alilog") | ||
| 14 | + lxalilog.InitAliLog(lxalilog.MapAlilogConfig{ | ||
| 15 | + Endpoint: logm["endpoint"], | ||
| 16 | + AccessKeyId: logm["accesskeyid"], | ||
| 17 | + AccessKeySecret: logm["accesskeysecret"], | ||
| 18 | + Project: logm["project"], | ||
| 19 | + AppNaame: appName, | ||
| 20 | + On: logm["on"], | ||
| 21 | + Debug: logm["debug"], | ||
| 22 | + TableError: "api_code_merge", | ||
| 23 | + TableDebug: logm["tabledebug"], | ||
| 24 | + Env: beego.AppConfig.String("env"), | ||
| 25 | + }) | ||
| 26 | + | ||
| 27 | + lalilog.InitAliLog(lalilog.MapAlilogConfig{ | ||
| 28 | + Endpoint: logm["endpoint"], | ||
| 29 | + AccessKeyId: logm["accesskeyid"], | ||
| 30 | + AccessKeySecret: logm["accesskeysecret"], | ||
| 31 | + Project: logm["project"], | ||
| 32 | + On: logm["on"], | ||
| 33 | + Debug: logm["debug"], | ||
| 34 | + TableError: logm["tableerror"], | ||
| 35 | + TableDebug: logm["tabledebug"], | ||
| 36 | + Env: beego.AppConfig.String("env"), | ||
| 37 | + }) | ||
| 38 | + | ||
| 39 | + fmt.Println(appName + " alilog init success") | ||
| 40 | +} |
| @@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
| 1 | +package zlog | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "apigame/common/zconst" | ||
| 5 | + "apigame/util/util-lx/lxbeego" | ||
| 6 | + "fmt" | ||
| 7 | + "github.com/astaxie/beego" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func Init() { | ||
| 11 | + | ||
| 12 | + // 初始化日志文件 | ||
| 13 | + logconfig, _ := beego.AppConfig.GetSection("log") | ||
| 14 | + logconfig["filename"] = logconfig["path"] + "api.log" | ||
| 15 | + | ||
| 16 | + if err := lxbeego.Inits(logconfig); err != nil { | ||
| 17 | + fmt.Println("lxbeelog.Inits Error::" + err.Error()) | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + fmt.Println(zconst.AppName + " beelog init success") | ||
| 21 | +} |
| @@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
| 1 | +package zredis |
dto/inits.go
| @@ -2,28 +2,15 @@ package dto | @@ -2,28 +2,15 @@ package dto | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "apigame/service/constd" | 4 | "apigame/service/constd" |
| 5 | - "apigame/util/util-lx/lxalilog" | ||
| 6 | - "apigame/util/util-lx/lxbeego" | ||
| 7 | "apigame/util/util-lx/lxmysql" | 5 | "apigame/util/util-lx/lxmysql" |
| 8 | "fmt" | 6 | "fmt" |
| 9 | "github.com/astaxie/beego" | 7 | "github.com/astaxie/beego" |
| 10 | - lalilog "github.com/lixu-any/go-tools/ali/log" | ||
| 11 | ) | 8 | ) |
| 12 | 9 | ||
| 13 | func Inits() (err error) { | 10 | func Inits() (err error) { |
| 14 | 11 | ||
| 15 | appname := beego.AppConfig.String("appname") | 12 | appname := beego.AppConfig.String("appname") |
| 16 | 13 | ||
| 17 | - // 初始化日志文件 | ||
| 18 | - logconfig, _ := beego.AppConfig.GetSection("log") | ||
| 19 | - logconfig["filename"] = logconfig["path"] + "api.log" | ||
| 20 | - | ||
| 21 | - if err = lxbeego.Inits(logconfig); err != nil { | ||
| 22 | - fmt.Println("lxbeelog.Inits Error::" + err.Error()) | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - fmt.Println(appname + " beelog init success") | ||
| 26 | - | ||
| 27 | ////初始化Redis | 14 | ////初始化Redis |
| 28 | //redisconfig, _ := beego.AppConfig.GetSection("redis") | 15 | //redisconfig, _ := beego.AppConfig.GetSection("redis") |
| 29 | //var mredisconfig lxredis.MapRedisConfig | 16 | //var mredisconfig lxredis.MapRedisConfig |
| @@ -63,8 +50,6 @@ func Inits() (err error) { | @@ -63,8 +50,6 @@ func Inits() (err error) { | ||
| 63 | fmt.Println(appname + " dbs::" + conn.Name + " init success") | 50 | fmt.Println(appname + " dbs::" + conn.Name + " init success") |
| 64 | } | 51 | } |
| 65 | 52 | ||
| 66 | - initAlilog(appname) | ||
| 67 | - | ||
| 68 | //// 初始化数数打点 | 53 | //// 初始化数数打点 |
| 69 | //_ = thinkingdata.InitThinkData() | 54 | //_ = thinkingdata.InitThinkData() |
| 70 | // | 55 | // |
| @@ -75,35 +60,3 @@ func Inits() (err error) { | @@ -75,35 +60,3 @@ func Inits() (err error) { | ||
| 75 | 60 | ||
| 76 | return | 61 | return |
| 77 | } | 62 | } |
| 78 | - | ||
| 79 | -func initAlilog(appname string) { | ||
| 80 | - | ||
| 81 | - //初始化阿里云日志 | ||
| 82 | - logm, _ := beego.AppConfig.GetSection("alilog") | ||
| 83 | - lxalilog.InitAliLog(lxalilog.MapAlilogConfig{ | ||
| 84 | - Endpoint: logm["endpoint"], | ||
| 85 | - AccessKeyId: logm["accesskeyid"], | ||
| 86 | - AccessKeySecret: logm["accesskeysecret"], | ||
| 87 | - Project: logm["project"], | ||
| 88 | - AppNaame: appname, | ||
| 89 | - On: logm["on"], | ||
| 90 | - Debug: logm["debug"], | ||
| 91 | - TableError: "api_code_merge", | ||
| 92 | - TableDebug: logm["tabledebug"], | ||
| 93 | - Env: beego.AppConfig.String("env"), | ||
| 94 | - }) | ||
| 95 | - | ||
| 96 | - lalilog.InitAliLog(lalilog.MapAlilogConfig{ | ||
| 97 | - Endpoint: logm["endpoint"], | ||
| 98 | - AccessKeyId: logm["accesskeyid"], | ||
| 99 | - AccessKeySecret: logm["accesskeysecret"], | ||
| 100 | - Project: logm["project"], | ||
| 101 | - On: logm["on"], | ||
| 102 | - Debug: logm["debug"], | ||
| 103 | - TableError: logm["tableerror"], | ||
| 104 | - TableDebug: logm["tabledebug"], | ||
| 105 | - Env: beego.AppConfig.String("env"), | ||
| 106 | - }) | ||
| 107 | - | ||
| 108 | - fmt.Println(appname + " alilog init success") | ||
| 109 | -} |
main.go
| 1 | package main | 1 | package main |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "apigame/common/zconst" | ||
| 5 | + "apigame/common/zlog" | ||
| 4 | "apigame/dto" | 6 | "apigame/dto" |
| 5 | _ "apigame/routers" | 7 | _ "apigame/routers" |
| 6 | "apigame/service/cardholder" | 8 | "apigame/service/cardholder" |
| @@ -27,10 +29,21 @@ func main() { | @@ -27,10 +29,21 @@ func main() { | ||
| 27 | beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger" | 29 | beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger" |
| 28 | } | 30 | } |
| 29 | 31 | ||
| 32 | + Init() | ||
| 33 | + | ||
| 34 | + beego.Run() | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +func Init() { | ||
| 38 | + | ||
| 39 | + zconst.AppName = beego.AppConfig.String("appname") | ||
| 40 | + | ||
| 41 | + zlog.Init() | ||
| 42 | + | ||
| 30 | _ = dto.Inits() | 43 | _ = dto.Inits() |
| 31 | 44 | ||
| 45 | + zlog.InitAliLog(zconst.AppName) | ||
| 46 | + | ||
| 32 | // 初始化配置 | 47 | // 初始化配置 |
| 33 | cardholder.Init() | 48 | cardholder.Init() |
| 34 | - | ||
| 35 | - beego.Run() | ||
| 36 | } | 49 | } |