Commit 741161ab by mushishixian

整合日志包

parent 7c66b1b2
......@@ -3,6 +3,7 @@ package boot
import (
"search_server/pkg/config"
"search_server/pkg/gredis"
"search_server/pkg/logger"
"search_server/pkg/mongo"
"search_server/pkg/mysql"
)
......@@ -20,5 +21,8 @@ func Boot(configPath string) (err error) {
if err = mongo.SetUp(); err != nil {
return
}
if err = logger.SetUp(); err != nil {
return
}
return
}
......@@ -5,13 +5,15 @@ go 1.14
require (
github.com/gin-gonic/gin v1.6.3
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/gomodule/redigo v2.0.1-0.20180401191855-9352ab68be13+incompatible
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/jinzhu/gorm v1.9.12
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/goconvey v1.6.4 // 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
import (
"flag"
"fmt"
"log"
"github.com/go-kratos/kratos/pkg/log"
"search_server/boot"
"search_server/pkg/config"
"search_server/pkg/es"
)
func main() {
......@@ -14,33 +11,39 @@ func main() {
flag.StringVar(&path, "config", "conf/config.ini", "配置文件")
flag.Parse()
if err := boot.Boot(path); err != nil {
log.Println(err)
log.Error("%s", err)
}
fmt.Println(es.CurlES(config.Get("es.index_name").String(), `{
"query": {
"bool": {
"filter": [
{
"term": {
"goods_id": "1154020374326836400"
}
}
]
}
},
"sort": [
{
"single_price": {
"order": "asc"
}
},
{
"_score": {
"order": "desc"
}
}
],
"from": 0,
"size": 10
}`))
//logger.Warn("test")
//logger.Warn("warn555555555555555555555555555555")
//logger.Info("info记录日志555555555555555555555555555555")
//logger.Error("Error记录日志555555555555555555555555555555")
//logger.Fatal("Fatal记录日志555555555555555555555555555555")
// fmt.Println(es.CurlES(config.Get("es.index_name").String(), `{
// "query": {
// "bool": {
// "filter": [
// {
// "term": {
// "goods_id": "1154020374326836400"
// }
// }
// ]
// }
// },
// "sort": [
// {
// "single_price": {
// "order": "asc"
// }
// },
// {
// "_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