作者 yangfu

日志修改

@@ -58,6 +58,8 @@ spec: @@ -58,6 +58,8 @@ spec:
58 value: "1" 58 value: "1"
59 - name: ERROR_BASE_CODE_MULTIPLE 59 - name: ERROR_BASE_CODE_MULTIPLE
60 value: "1000" 60 value: "1000"
  61 + - name: ENABLE_KAFKA_LOG
  62 + value: "true"
61 - name: USER_MODULE_HOST 63 - name: USER_MODULE_HOST
62 value: "http://allied-creation-user-dev.fjmaimaimai.com" 64 value: "http://allied-creation-user-dev.fjmaimaimai.com"
63 - name: REDIS_HOST 65 - name: REDIS_HOST
@@ -2,11 +2,20 @@ package main @@ -2,11 +2,20 @@ package main
2 2
3 import ( 3 import (
4 "github.com/beego/beego/v2/server/web" 4 "github.com/beego/beego/v2/server/web"
  5 + "github.com/linmadan/egglib-go/log/logrus"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
  7 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
5 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg" 8 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
  10 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
6 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego" 11 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego"
7 ) 12 )
8 13
9 func main() { 14 func main() {
10 // web主服务 15 // web主服务
  16 + if constant.ENABLE_KAFKA_LOG {
  17 + w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOSTS, constant.TOPIC_LOG_STASH, false)
  18 + log.Logger.AddHook(w)
  19 + }
11 web.Run() 20 web.Run()
12 } 21 }
@@ -3,7 +3,7 @@ package constant @@ -3,7 +3,7 @@ package constant
3 import "os" 3 import "os"
4 4
5 // kafka 地址 5 // kafka 地址
6 -var KAFKA_HOSTS = "" 6 +var KAFKA_HOSTS = "192.168.0.250:9092,192.168.0.251:9092,192.168.0.252:9092"
7 7
8 // kafka topic log stash 8 // kafka topic log stash
9 var TOPIC_LOG_STASH = "go_stash_dev" 9 var TOPIC_LOG_STASH = "go_stash_dev"