فهرست منبع

wip:日志包修改

wangkaiyue 2 سال پیش
والد
کامیت
51cc6b8213

+ 18 - 16
jyBXSubscribe/api/bxsubscribe.go

@@ -1,25 +1,26 @@
 package main
 
 import (
-        "app.yhyue.com/moapp/jybase/endless"
-        "bp.jydev.jianyu360.cn/BaseService/gateway/core/node"
-        "fmt"
-        "log"
-        "net/http"
-        "os"
-        "os/signal"
-        "syscall"
+	"app.yhyue.com/moapp/jybase/endless"
+	logrusx "app.yhyue.com/moapp/jylogx/logx"
+	"bp.jydev.jianyu360.cn/BaseService/gateway/core/node"
+	"fmt"
+	"github.com/zeromicro/go-zero/core/logx"
+	"jyBXSubscribe/api/internal/handler"
+	"jyBXSubscribe/api/internal/svc"
+	"log"
+	"net/http"
+	"os"
+	"os/signal"
+	"syscall"
 
-        "jyBXSubscribe/api/internal/handler"
-        "jyBXSubscribe/api/internal/svc"
-
-        MC "app.yhyue.com/moapp/jybase/common"
-        "github.com/zeromicro/go-zero/rest"
-        IC "jyBXSubscribe/api/init"
+	MC "app.yhyue.com/moapp/jybase/common"
+	"github.com/zeromicro/go-zero/rest"
+	IC "jyBXSubscribe/api/init"
 )
 
 func main() {
-        //注册代理服务
+	//注册代理服务
 	closeNotify, err := node.NewNode(IC.C.Gateway.Etcd...).Register(IC.C.Gateway.ServerCode, MC.InterfaceToStr(IC.C.Port))
 	if err != nil {
 		panic(err)
@@ -45,7 +46,8 @@ func main() {
 		}
 	})
 	handler.RegisterHandlers(server, ctx)
-
+	//日志记录
+	logx.SetWriter(logrusx.NewLogrusWriter())
 	fmt.Printf("Starting server at %s:%d...\n", IC.C.Host, IC.C.Port)
 	server.Start()
 

+ 0 - 15
jyBXSubscribe/api/init/init.go

@@ -9,22 +9,18 @@ import (
 
 	MC "app.yhyue.com/moapp/jybase/common"
 	"github.com/zeromicro/go-zero/core/conf"
-	"github.com/zeromicro/go-zero/core/logx"
 )
 
 var configFile = flag.String("cf", "etc/bxsubscribe-api.yaml", "the config file")
 
 var C config.Config
 
-//
 var logFile = flag.String("lf", "etc/logs.yaml", "the log file")
 var logc entity.Logc
 
-//
 var dbFile = flag.String("df", "etc/db.yaml", "the db file")
 var DB config.Db
 
-//
 var routesFile = flag.String("rf", "etc/routes.yaml", "the routes file")
 var Routes config.Routes
 var ExcludeUrl = []*regexp.Regexp{}
@@ -38,17 +34,6 @@ func init() {
 	MongoDBInit(&DB.Mongo)
 	//初始化日志信息
 	conf.MustLoad(*logFile, &logc)
-	if len(logc.Level) > 0 {
-		for _, v := range logc.Level {
-			logx.MustSetup(logx.LogConf{
-				Mode:     logc.Mode,
-				Path:     logc.Path,
-				Level:    v,
-				KeepDays: logc.KeepDays,
-			})
-			logx.Info(v, "--日志记录")
-		}
-	}
 	//读取路由配置
 	conf.MustLoad(*routesFile, &Routes)
 	if len(Routes.ExcludeRoute) > 0 {

+ 74 - 53
jyBXSubscribe/go.mod

@@ -4,16 +4,19 @@ go 1.18
 
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230420060106-a9c3f4187463
+	app.yhyue.com/moapp/jylog v0.0.0-20230506054155-60c3d54a2cf6
+	app.yhyue.com/moapp/jylogx v0.0.0-20230506054359-10daf2b78830
 	app.yhyue.com/moapp/jypkg v0.0.0-20230420060744-ff53e7ca6f47
 	bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4
 	bp.jydev.jianyu360.cn/BaseService/jyCodeService v0.0.0-20220927093612-72958b15cdf0
 	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230222052351-9d6fad062447
 	github.com/go-sql-driver/mysql v1.7.0
 	github.com/gogf/gf/v2 v2.0.6
-	github.com/zeromicro/go-zero v1.4.4
-	go.mongodb.org/mongo-driver v1.11.1
-	google.golang.org/grpc v1.53.0
-	google.golang.org/protobuf v1.28.1
+	github.com/sirupsen/logrus v1.9.0
+	github.com/zeromicro/go-zero v1.5.2
+	go.mongodb.org/mongo-driver v1.11.4
+	google.golang.org/grpc v1.54.0
+	google.golang.org/protobuf v1.30.0
 )
 
 require (
@@ -24,102 +27,120 @@ require (
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.13 // indirect
 	github.com/BurntSushi/toml v0.4.1 // indirect
 	github.com/beorn7/perks v1.0.1 // indirect
-	github.com/cenkalti/backoff/v4 v4.1.3 // indirect
+	github.com/cenkalti/backoff/v4 v4.2.1 // indirect
 	github.com/cespare/xxhash/v2 v2.2.0 // indirect
 	github.com/clbanning/mxj/v2 v2.5.5 // indirect
-	github.com/coreos/go-semver v0.3.0 // indirect
-	github.com/coreos/go-systemd/v22 v22.3.2 // indirect
+	github.com/coreos/go-semver v0.3.1 // indirect
+	github.com/coreos/go-systemd/v22 v22.5.0 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
 	github.com/dchest/captcha v0.0.0-20200903113550-03f5f0333e1f // indirect
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
-	github.com/fatih/color v1.13.0 // indirect
+	github.com/emicklei/go-restful/v3 v3.9.0 // indirect
+	github.com/fatih/color v1.15.0 // indirect
 	github.com/felixge/fgprof v0.9.3 // indirect
-	github.com/fsnotify/fsnotify v1.5.1 // indirect
+	github.com/fsnotify/fsnotify v1.6.0 // indirect
 	github.com/garyburd/redigo v1.6.2 // indirect
-	github.com/go-logr/logr v1.2.3 // indirect
+	github.com/go-logr/logr v1.2.4 // indirect
 	github.com/go-logr/stdr v1.2.2 // indirect
+	github.com/go-openapi/jsonpointer v0.19.6 // indirect
+	github.com/go-openapi/jsonreference v0.20.1 // indirect
+	github.com/go-openapi/swag v0.22.3 // indirect
 	github.com/go-redis/redis/v8 v8.11.5 // indirect
 	github.com/gogo/protobuf v1.3.2 // indirect
-	github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
+	github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
 	github.com/golang/mock v1.6.0 // indirect
-	github.com/golang/protobuf v1.5.2 // indirect
+	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
 	github.com/gomodule/redigo v2.0.0+incompatible // indirect
+	github.com/google/gnostic v0.5.7-v3refs // indirect
 	github.com/google/go-cmp v0.5.9 // indirect
 	github.com/google/gofuzz v1.2.0 // indirect
 	github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
 	github.com/google/uuid v1.3.0 // indirect
-	github.com/googleapis/gnostic v0.5.5 // indirect
 	github.com/gorilla/websocket v1.5.0 // indirect
 	github.com/grokify/html-strip-tags-go v0.0.1 // indirect
-	github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
+	github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
+	github.com/hashicorp/hcl v1.0.0 // indirect
 	github.com/jinzhu/inflection v1.0.0 // indirect
 	github.com/jinzhu/now v1.1.1 // indirect
 	github.com/josharian/intern v1.0.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
-	github.com/klauspost/compress v1.13.6 // indirect
+	github.com/klauspost/compress v1.15.15 // indirect
 	github.com/longbridgeapp/sqlparser v0.3.1 // indirect
+	github.com/magiconair/properties v1.8.7 // indirect
 	github.com/mailru/easyjson v0.7.7 // indirect
 	github.com/mattn/go-colorable v0.1.13 // indirect
-	github.com/mattn/go-isatty v0.0.16 // indirect
+	github.com/mattn/go-isatty v0.0.17 // indirect
 	github.com/mattn/go-runewidth v0.0.13 // indirect
-	github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
+	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
+	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
+	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
 	github.com/olekukonko/tablewriter v0.0.5 // indirect
 	github.com/olivere/elastic v6.2.37+incompatible // indirect
 	github.com/olivere/elastic/v7 v7.0.22 // indirect
-	github.com/openzipkin/zipkin-go v0.4.0 // indirect
-	github.com/pelletier/go-toml/v2 v2.0.6 // indirect
+	github.com/openzipkin/zipkin-go v0.4.1 // indirect
+	github.com/pelletier/go-toml/v2 v2.0.7 // indirect
 	github.com/pkg/errors v0.9.1 // indirect
-	github.com/prometheus/client_golang v1.13.0 // indirect
-	github.com/prometheus/client_model v0.2.0 // indirect
-	github.com/prometheus/common v0.37.0 // indirect
-	github.com/prometheus/procfs v0.8.0 // indirect
+	github.com/prometheus/client_golang v1.15.0 // indirect
+	github.com/prometheus/client_model v0.3.0 // indirect
+	github.com/prometheus/common v0.42.0 // indirect
+	github.com/prometheus/procfs v0.9.0 // indirect
 	github.com/rivo/uniseg v0.2.0 // indirect
 	github.com/spaolacci/murmur3 v1.1.0 // indirect
+	github.com/spf13/afero v1.9.3 // indirect
+	github.com/spf13/cast v1.5.0 // indirect
+	github.com/spf13/jwalterweatherman v1.1.0 // indirect
+	github.com/spf13/pflag v1.0.5 // indirect
+	github.com/spf13/viper v1.15.0 // indirect
+	github.com/subosito/gotenv v1.4.2 // indirect
 	github.com/xdg-go/pbkdf2 v1.0.0 // indirect
 	github.com/xdg-go/scram v1.1.1 // indirect
 	github.com/xdg-go/stringprep v1.0.3 // indirect
 	github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
-	go.etcd.io/etcd/api/v3 v3.5.5 // indirect
-	go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
-	go.etcd.io/etcd/client/v3 v3.5.5 // indirect
-	go.opentelemetry.io/otel v1.11.0 // indirect
-	go.opentelemetry.io/otel/exporters/jaeger v1.11.0 // indirect
-	go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.0 // indirect
-	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.0 // indirect
-	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.0 // indirect
-	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.10.0 // indirect
-	go.opentelemetry.io/otel/exporters/zipkin v1.11.0 // indirect
-	go.opentelemetry.io/otel/sdk v1.11.0 // indirect
-	go.opentelemetry.io/otel/trace v1.11.0 // indirect
+	go.etcd.io/etcd/api/v3 v3.5.8 // indirect
+	go.etcd.io/etcd/client/pkg/v3 v3.5.8 // indirect
+	go.etcd.io/etcd/client/v3 v3.5.8 // indirect
+	go.opentelemetry.io/otel v1.15.1 // indirect
+	go.opentelemetry.io/otel/exporters/jaeger v1.15.1 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.15.1 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.15.1 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.15.1 // indirect
+	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.15.1 // indirect
+	go.opentelemetry.io/otel/exporters/zipkin v1.15.1 // indirect
+	go.opentelemetry.io/otel/sdk v1.15.1 // indirect
+	go.opentelemetry.io/otel/trace v1.15.1 // indirect
 	go.opentelemetry.io/proto/otlp v0.19.0 // indirect
-	go.uber.org/atomic v1.9.0 // indirect
-	go.uber.org/automaxprocs v1.5.1 // indirect
-	go.uber.org/multierr v1.8.0 // indirect
-	go.uber.org/zap v1.21.0 // indirect
-	golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
-	golang.org/x/net v0.5.0 // indirect
-	golang.org/x/oauth2 v0.4.0 // indirect
+	go.uber.org/atomic v1.10.0 // indirect
+	go.uber.org/automaxprocs v1.5.2 // indirect
+	go.uber.org/multierr v1.9.0 // indirect
+	go.uber.org/zap v1.24.0 // indirect
+	golang.org/x/crypto v0.6.0 // indirect
+	golang.org/x/net v0.9.0 // indirect
+	golang.org/x/oauth2 v0.5.0 // indirect
 	golang.org/x/sync v0.1.0 // indirect
-	golang.org/x/sys v0.4.0 // indirect
-	golang.org/x/term v0.4.0 // indirect
-	golang.org/x/text v0.6.0 // indirect
+	golang.org/x/sys v0.7.0 // indirect
+	golang.org/x/term v0.7.0 // indirect
+	golang.org/x/text v0.9.0 // indirect
 	golang.org/x/time v0.3.0 // indirect
 	google.golang.org/appengine v1.6.7 // indirect
-	google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
+	google.golang.org/genproto v0.0.0-20230123190316-2c411cf9d197 // indirect
 	gopkg.in/inf.v0 v0.9.1 // indirect
+	gopkg.in/ini.v1 v1.67.0 // indirect
+	gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
 	gopkg.in/yaml.v2 v2.4.0 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 	gorm.io/driver/mysql v1.0.5 // indirect
 	gorm.io/gorm v1.21.3 // indirect
-	k8s.io/api v0.22.9 // indirect
-	k8s.io/apimachinery v0.22.9 // indirect
-	k8s.io/client-go v0.22.9 // indirect
-	k8s.io/klog/v2 v2.80.1 // indirect
-	k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 // indirect
-	sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
-	sigs.k8s.io/yaml v1.2.0 // indirect
+	k8s.io/api v0.26.3 // indirect
+	k8s.io/apimachinery v0.27.0-alpha.3 // indirect
+	k8s.io/client-go v0.26.3 // indirect
+	k8s.io/klog/v2 v2.90.1 // indirect
+	k8s.io/kube-openapi v0.0.0-20230307230338-69ee2d25a840 // indirect
+	k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
+	sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
+	sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
+	sigs.k8s.io/yaml v1.3.0 // indirect
 )

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 126 - 437
jyBXSubscribe/go.sum


+ 12 - 11
jyBXSubscribe/rpc/bxsubscribe.go

@@ -1,25 +1,24 @@
 package main
 
 import (
+	MC "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/endless"
+	logrusx "app.yhyue.com/moapp/jylogx/logx"
 	"flag"
 	"fmt"
-	"log"
-
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/os/gcfg"
-
-	IC "jyBXSubscribe/rpc/init"
-	"jyBXSubscribe/rpc/internal/server"
-	"jyBXSubscribe/rpc/internal/svc"
-	"jyBXSubscribe/rpc/type/bxsubscribe"
-
-	MC "app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/endless"
 	"github.com/zeromicro/go-zero/core/conf"
+	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/service"
 	"github.com/zeromicro/go-zero/zrpc"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/reflection"
+	IC "jyBXSubscribe/rpc/init"
+	"jyBXSubscribe/rpc/internal/server"
+	"jyBXSubscribe/rpc/internal/svc"
+	"jyBXSubscribe/rpc/type/bxsubscribe"
+	"log"
 )
 
 var configF = flag.String("cf", "etc/bxsubscribe.yaml", "the config file")
@@ -27,9 +26,9 @@ var dbFile = flag.String("df", "etc/db.yaml", "the db file")
 var logFile = flag.String("lf", "etc/logs.yaml", "the log file")
 
 func main() {
-
 	//初始化基本配置
 	g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("etc/config.yaml")
+	//logx.SetWriter(logx.NewWriter(jylog.GetWriter()))
 	conf.MustLoad(*configF, &IC.C)
 	//初始化数据库配置
 	conf.MustLoad(*dbFile, &IC.DB)
@@ -54,7 +53,9 @@ func main() {
 			reflection.Register(grpcServer)
 		}
 	})
+
 	//日志记录
+	logx.SetWriter(logrusx.NewLogrusWriter())
 	//s.AddUnaryInterceptors(util.CustomInterceptors)
 	defer s.Stop()
 	fmt.Printf("Starting rpc server at %s...\n", IC.C.ListenOn)

+ 15 - 16
jyBXSubscribe/rpc/init/init.go

@@ -1,9 +1,6 @@
 package init
 
 import (
-	"jyBXSubscribe/entity"
-	"jyBXSubscribe/rpc/internal/config"
-
 	"app.yhyue.com/moapp/jypkg/compatible"
 	"app.yhyue.com/moapp/jypkg/middleground"
 	codePb "bp.jydev.jianyu360.cn/BaseService/jyCodeService/rpc/codeservice/codeservice"
@@ -11,16 +8,17 @@ import (
 	"github.com/zeromicro/go-zero/core/discov"
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/zrpc"
+	"jyBXSubscribe/entity"
+	"jyBXSubscribe/rpc/internal/config"
 )
 
 var C config.Config
 var err error
 var CodeLib codePb.CodeService
 
-//
 var DB config.Db
 
-//var codLib
+// var codLib
 var Logc entity.Logc
 
 func InitC() {
@@ -37,17 +35,18 @@ func InitC() {
 		RegPowerCheckCenter(C.PowerCheckCenterKey).
 		RegEntManageApplication(C.EntManageApplication)
 	Compatible = compatible.NewCompatible(&Mgo, BaseServiceMysql, MainMysql, Middleground)
-	if len(Logc.Level) > 0 {
-		for _, v := range Logc.Level {
-			logx.MustSetup(logx.LogConf{
-				Mode:     Logc.Mode,
-				Path:     Logc.Path,
-				Level:    v,
-				KeepDays: Logc.KeepDays,
-			})
-			logx.Info(v, "--日志记录")
-		}
-	}
+	//if len(Logc.Level) > 0 {
+	//	for _, v := range Logc.Level {
+	//		logx.MustSetup(logx.LogConf{
+	//			Mode:     Logc.Mode,
+	//			Path:     Logc.Path,
+	//			Level:    v,
+	//			KeepDays: Logc.KeepDays,
+	//		})
+	//		logx.Info(v, "--日志记录")
+	//	}
+	//}
+	//logx.SetWriter(logrusx.NewLogrusWriter())
 	//代码表服务加载
 	codeClient := zrpc.MustNewClient(zrpc.RpcClientConf{
 		Etcd: discov.EtcdConf{

+ 1 - 0
jyBXSubscribe/rpc/model/push.go

@@ -645,6 +645,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			findSql = fmt.Sprintf("%s from %s  a STRAIGHT_JOIN %s b ON 1=1 %s and a.infoid = b.infoid  %s where %s"+
 				" order by a.date desc,a.id desc", findSql, aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, userStr, leftJoinStr, strings.Join(querys, " and "))
 		}
+		logx.Error("--------------------------")
 		//查询总数
 		logx.Info("countSql", countSql)
 		count = spqp.BaseServiceMysql.CountBySql(countSql)

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است