go-zero
go-zero copied to clipboard
logx setting from etc/*.yaml will not be working, if the logx.XX is used in init() or svc.NewServiceContext(c)
Describe the bug
The logx can be setup once (i.e. #2188). If the logx is used in some package init function or in the function svc.NewServiceContext(c), the logx mode would be the "console" defaultly. As a result, the logx setting from etc/*.yaml will not be working.
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
svr := server.NewAppassetServer(ctx)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
apppb.RegisterAppassetServer(grpcServer, svr)
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()