From a8d78832df106794758f42812e8fc93810e3d819 Mon Sep 17 00:00:00 2001 From: hoteas <等> Date: Wed, 3 Aug 2022 12:07:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=85=8D=E7=BD=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application.go | 13 +++++++--- code/config.go | 8 ++++++ example/config/config.json | 9 ++++--- example/config/config1.json | 49 +++++++++++++++++++++++++++++++++++++ log/logrus.go | 3 +++ 5 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 example/config/config1.json diff --git a/application.go b/application.go index e71f340..3c79203 100644 --- a/application.go +++ b/application.go @@ -7,6 +7,7 @@ import ( . "code.hoteas.com/golang/hotime/db" . "code.hoteas.com/golang/hotime/log" "database/sql" + "fmt" "github.com/sirupsen/logrus" "io/ioutil" "net/http" @@ -237,10 +238,8 @@ func (that *Application) SetConfig(configPath ...string) { } - that.Log = GetLog(that.Config.GetString("logFile"), true) - that.Error = Error{Logger: that.Log} - if that.Config.Get("webConnectLogShow") == nil || that.Config.GetBool("webConnectLogShow") { - that.WebConnectLog = GetLog(that.Config.GetString("webConnectLogFile"), false) + if that.Error.GetError() != nil { + fmt.Println(that.Error.GetError().Error()) } //文件如果损坏则不写入配置防止配置文件数据丢失 @@ -267,6 +266,12 @@ func (that *Application) SetConfig(configPath ...string) { } + that.Log = GetLog(that.Config.GetString("logFile"), true) + that.Error = Error{Logger: that.Log} + if that.Config.Get("webConnectLogShow") == nil || that.Config.GetBool("webConnectLogShow") { + that.WebConnectLog = GetLog(that.Config.GetString("webConnectLogFile"), false) + } + } // SetConnectListener 连接判断,返回false继续传输至控制层,true则停止传输 diff --git a/code/config.go b/code/config.go index 4fb03e0..d095095 100644 --- a/code/config.go +++ b/code/config.go @@ -8,6 +8,14 @@ var Config = Map{ "name": "HoTimeDashBoard", //"id": "2f92h3herh23rh2y8", "label": "HoTime管理平台", + "labelConfig": Map{ + "show": "开启", + "add": "添加", + "delete": "删除", + "edit": "编辑", + "info": "查看详情", + "download": "下载清单", + }, "menus": []Map{ //{"label": "平台首页", "name": "HelloWorld", "icon": "el-icon-s-home"}, //{"label": "测试表格", "table": "table", "icon": "el-icon-suitcase"}, diff --git a/example/config/config.json b/example/config/config.json index ee1cf4c..25953e7 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -23,12 +23,13 @@ ], "db": { "mysql": { - "host": "192.168.6.253", - "name": "dgs-cms", - "password": "dasda8454456", + "host": "192.168.2.20", + "name": "gov_crawler", + "password": "fh22y8b882d", "port": "3306", + "prefix": "", "user": "root" - } + }, "defFile": [ "index.html", diff --git a/example/config/config1.json b/example/config/config1.json new file mode 100644 index 0000000..63f1577 --- /dev/null +++ b/example/config/config1.json @@ -0,0 +1,49 @@ +{ + "cache": { + "db": { + "db": false, + "session": true, + "timeout": 7200 + }, + "memory": { + "db": true, + "session": true, + "timeout": 7200 + } + }, + "codeConfig": [ + { + "config": "config/admin.json", + "configDB": "config/adminDB.json", + "mode": 0, + "name": "", + "rule": "config/rule.json", + "table": "admin" + } + ], + "db": { + "mysql": { + "host": "192.168.2.20", + "name": "gov_crawler", + "password": "fh22y8b882d", + "port": "3306", + "prefix": "", + "user": "root" + } + }, + "defFile": [ + "index.html", + "index.htm" + ], + "error": { + "1": "内部系统异常", + "2": "访问权限异常", + "3": "请求参数异常", + "4": "数据处理异常", + "5": "数据结果异常" + }, + "mode": 2, + "port": "8081", + "sessionName": "HOTIME", + "tpt": "tpt" +} \ No newline at end of file diff --git a/log/logrus.go b/log/logrus.go index 774f067..bd401a2 100644 --- a/log/logrus.go +++ b/log/logrus.go @@ -94,6 +94,9 @@ func findCaller(skip int) string { if file == "code/makecode.go" { file, line = getCaller(skip + i + j) } + if strings.Index(file, "common/") == 0 { + file, line = getCaller(skip + i + j) + } if strings.Contains(file, "application.go") { file, line = getCaller(skip + i + j) }