Commit 741161ab by mushishixian

整合日志包

parent 7c66b1b2
...@@ -3,6 +3,7 @@ package boot ...@@ -3,6 +3,7 @@ package boot
import ( import (
"search_server/pkg/config" "search_server/pkg/config"
"search_server/pkg/gredis" "search_server/pkg/gredis"
"search_server/pkg/logger"
"search_server/pkg/mongo" "search_server/pkg/mongo"
"search_server/pkg/mysql" "search_server/pkg/mysql"
) )
...@@ -20,5 +21,8 @@ func Boot(configPath string) (err error) { ...@@ -20,5 +21,8 @@ func Boot(configPath string) (err error) {
if err = mongo.SetUp(); err != nil { if err = mongo.SetUp(); err != nil {
return return
} }
if err = logger.SetUp(); err != nil {
return
}
return return
} }
...@@ -5,13 +5,15 @@ go 1.14 ...@@ -5,13 +5,15 @@ go 1.14
require ( require (
github.com/gin-gonic/gin v1.6.3 github.com/gin-gonic/gin v1.6.3
github.com/go-ini/ini v1.44.0 github.com/go-ini/ini v1.44.0
github.com/go-kratos/kratos v0.5.0
github.com/golang/protobuf v1.4.2 github.com/golang/protobuf v1.4.2
github.com/gomodule/redigo v2.0.1-0.20180401191855-9352ab68be13+incompatible github.com/gomodule/redigo v2.0.1-0.20180401191855-9352ab68be13+incompatible
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/ichunt2019/logger v1.0.5
github.com/imroc/req v0.3.0 github.com/imroc/req v0.3.0
github.com/jinzhu/gorm v1.9.12 github.com/jinzhu/gorm v1.9.12
github.com/micro/go-micro/v2 v2.5.0 github.com/micro/go-micro/v2 v2.5.0
github.com/prometheus/common v0.6.0 github.com/prometheus/common v0.9.1
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 // indirect github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.5.1 // indirect github.com/stretchr/testify v1.5.1 // indirect
......
File mode changed
File mode changed
package logger
import (
"github.com/ichunt2019/logger"
)
func SetUp() (err error) {
logConfig := make(map[string]string)
logConfig["log_path"] = "logs"
logConfig["log_chan_size"] = "1000"
err = logger.InitLogger("file", logConfig)
if err != nil {
return err
}
logger.Init()
return
}
...@@ -2,11 +2,8 @@ package main ...@@ -2,11 +2,8 @@ package main
import ( import (
"flag" "flag"
"fmt" "github.com/go-kratos/kratos/pkg/log"
"log"
"search_server/boot" "search_server/boot"
"search_server/pkg/config"
"search_server/pkg/es"
) )
func main() { func main() {
...@@ -14,33 +11,39 @@ func main() { ...@@ -14,33 +11,39 @@ func main() {
flag.StringVar(&path, "config", "conf/config.ini", "配置文件") flag.StringVar(&path, "config", "conf/config.ini", "配置文件")
flag.Parse() flag.Parse()
if err := boot.Boot(path); err != nil { if err := boot.Boot(path); err != nil {
log.Println(err) log.Error("%s", err)
} }
fmt.Println(es.CurlES(config.Get("es.index_name").String(), `{ //logger.Warn("test")
"query": { //logger.Warn("warn555555555555555555555555555555")
"bool": { //logger.Info("info记录日志555555555555555555555555555555")
"filter": [ //logger.Error("Error记录日志555555555555555555555555555555")
{ //logger.Fatal("Fatal记录日志555555555555555555555555555555")
"term": {
"goods_id": "1154020374326836400" // fmt.Println(es.CurlES(config.Get("es.index_name").String(), `{
} // "query": {
} // "bool": {
] // "filter": [
} // {
}, // "term": {
"sort": [ // "goods_id": "1154020374326836400"
{ // }
"single_price": { // }
"order": "asc" // ]
} // }
}, // },
{ // "sort": [
"_score": { // {
"order": "desc" // "single_price": {
} // "order": "asc"
} // }
], // },
"from": 0, // {
"size": 10 // "_score": {
}`)) // "order": "desc"
// }
// }
// ],
// "from": 0,
// "size": 10
//}`))
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment