mirror of https://github.com/hashicorp/consul
logging: move init of grpclog
This line initializes global state. Moving it out of the constructor and closer to where logging is setup helps keep related things together.pull/8540/head
parent
33c401a16e
commit
f2373a5575
|
@ -23,7 +23,6 @@ import (
|
|||
"github.com/hashicorp/go-memdb"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/hashicorp/consul/acl"
|
||||
|
@ -354,9 +353,6 @@ func New(bd BaseDeps) (*Agent, error) {
|
|||
autoConf: bd.AutoConfig,
|
||||
}
|
||||
|
||||
// TODO: set globals somewhere else, not Agent.New
|
||||
grpclog.SetLoggerV2(logging.NewGRPCLogger(bd.RuntimeConfig.LogLevel, bd.Logger))
|
||||
|
||||
a.serviceManager = NewServiceManager(&a)
|
||||
|
||||
// TODO: do this somewhere else, maybe move to newBaseDeps
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/hashicorp/consul/logging"
|
||||
"github.com/hashicorp/consul/tlsutil"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
)
|
||||
|
||||
// TODO: BaseDeps should be renamed in the future once more of Agent.Start
|
||||
|
@ -66,6 +67,7 @@ func NewBaseDeps(configLoader ConfigLoader, logOut io.Writer) (BaseDeps, error)
|
|||
if err != nil {
|
||||
return d, err
|
||||
}
|
||||
grpclog.SetLoggerV2(logging.NewGRPCLogger(cfg.LogLevel, d.Logger))
|
||||
|
||||
for _, w := range warnings {
|
||||
d.Logger.Warn(w)
|
||||
|
|
|
@ -17,7 +17,7 @@ type GRPCLogger struct {
|
|||
// logger with Severity/Verbosity level appropriate for the given config.
|
||||
//
|
||||
// Note that grpclog has Info, Warning, Error, Fatal severity levels AND integer
|
||||
// verbosity levels for additional info. Verbose logs in glog are always INFO
|
||||
// verbosity levels for additional info. Verbose logs in hclog are always DEBUG
|
||||
// severity so we map Info,V0 to INFO, Info,V1 to DEBUG, and Info,V>1 to TRACE.
|
||||
func NewGRPCLogger(logLevel string, logger hclog.Logger) *GRPCLogger {
|
||||
return &GRPCLogger{
|
||||
|
|
Loading…
Reference in New Issue