mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #8994 from gyuho/grpc-proxy-log
*: discard only info when --debug=false, add "--debug" grpc-proxy start
This commit is contained in:
commit
3dd1c1b53c
@ -55,7 +55,7 @@ See [code changes](https://github.com/coreos/etcd/compare/v3.2.0...v3.3.0-rc.0)
|
|||||||
- Provide [error information in `/health`](https://github.com/coreos/etcd/pull/8312).
|
- Provide [error information in `/health`](https://github.com/coreos/etcd/pull/8312).
|
||||||
- e.g. `{"health":false,"errors":["NOSPACE"]}`.
|
- e.g. `{"health":false,"errors":["NOSPACE"]}`.
|
||||||
- Move [logging setup to embed package](https://github.com/coreos/etcd/pull/8810)
|
- Move [logging setup to embed package](https://github.com/coreos/etcd/pull/8810)
|
||||||
- Disable gRPC server log by default.
|
- Disable gRPC server info-level logs by default (can be enabled with `etcd --debug` flag).
|
||||||
- Use [monotonic time in Go 1.9](https://github.com/coreos/etcd/pull/8507) for `lease` package.
|
- Use [monotonic time in Go 1.9](https://github.com/coreos/etcd/pull/8507) for `lease` package.
|
||||||
- Warn on [empty hosts in advertise URLs](https://github.com/coreos/etcd/pull/8384).
|
- Warn on [empty hosts in advertise URLs](https://github.com/coreos/etcd/pull/8384).
|
||||||
- Address [advertise client URLs accepts empty hosts](https://github.com/coreos/etcd/issues/8379).
|
- Address [advertise client URLs accepts empty hosts](https://github.com/coreos/etcd/issues/8379).
|
||||||
|
@ -268,8 +268,11 @@ func (cfg *Config) SetupLogging() {
|
|||||||
if cfg.Debug {
|
if cfg.Debug {
|
||||||
capnslog.SetGlobalLogLevel(capnslog.DEBUG)
|
capnslog.SetGlobalLogLevel(capnslog.DEBUG)
|
||||||
grpc.EnableTracing = true
|
grpc.EnableTracing = true
|
||||||
|
// enable info, warning, error
|
||||||
|
grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr))
|
||||||
} else {
|
} else {
|
||||||
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
|
// only discard info
|
||||||
|
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
|
||||||
}
|
}
|
||||||
if cfg.LogPkgLevels != "" {
|
if cfg.LogPkgLevels != "" {
|
||||||
repoLog := capnslog.MustRepoLogger("github.com/coreos/etcd")
|
repoLog := capnslog.MustRepoLogger("github.com/coreos/etcd")
|
||||||
|
@ -17,6 +17,7 @@ package etcdmain
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -37,10 +38,12 @@ import (
|
|||||||
"github.com/coreos/etcd/pkg/transport"
|
"github.com/coreos/etcd/pkg/transport"
|
||||||
"github.com/coreos/etcd/proxy/grpcproxy"
|
"github.com/coreos/etcd/proxy/grpcproxy"
|
||||||
|
|
||||||
|
"github.com/coreos/pkg/capnslog"
|
||||||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
||||||
"github.com/soheilhy/cmux"
|
"github.com/soheilhy/cmux"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/grpclog"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -75,6 +78,8 @@ var (
|
|||||||
|
|
||||||
grpcProxyEnablePprof bool
|
grpcProxyEnablePprof bool
|
||||||
grpcProxyEnableOrdering bool
|
grpcProxyEnableOrdering bool
|
||||||
|
|
||||||
|
grpcProxyDebug bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -127,12 +132,26 @@ func newGRPCProxyStartCommand() *cobra.Command {
|
|||||||
// experimental flags
|
// experimental flags
|
||||||
cmd.Flags().BoolVar(&grpcProxyEnableOrdering, "experimental-serializable-ordering", false, "Ensure serializable reads have monotonically increasing store revisions across endpoints.")
|
cmd.Flags().BoolVar(&grpcProxyEnableOrdering, "experimental-serializable-ordering", false, "Ensure serializable reads have monotonically increasing store revisions across endpoints.")
|
||||||
cmd.Flags().StringVar(&grpcProxyLeasing, "experimental-leasing-prefix", "", "leasing metadata prefix for disconnected linearized reads.")
|
cmd.Flags().StringVar(&grpcProxyLeasing, "experimental-leasing-prefix", "", "leasing metadata prefix for disconnected linearized reads.")
|
||||||
|
|
||||||
|
cmd.Flags().BoolVar(&grpcProxyDebug, "debug", false, "Enable debug-level logging for grpc-proxy.")
|
||||||
|
|
||||||
return &cmd
|
return &cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func startGRPCProxy(cmd *cobra.Command, args []string) {
|
func startGRPCProxy(cmd *cobra.Command, args []string) {
|
||||||
checkArgs()
|
checkArgs()
|
||||||
|
|
||||||
|
capnslog.SetGlobalLogLevel(capnslog.INFO)
|
||||||
|
if grpcProxyDebug {
|
||||||
|
capnslog.SetGlobalLogLevel(capnslog.DEBUG)
|
||||||
|
grpc.EnableTracing = true
|
||||||
|
// enable info, warning, error
|
||||||
|
grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr))
|
||||||
|
} else {
|
||||||
|
// only discard info
|
||||||
|
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
|
||||||
|
}
|
||||||
|
|
||||||
tlsinfo := newTLS(grpcProxyListenCA, grpcProxyListenCert, grpcProxyListenKey)
|
tlsinfo := newTLS(grpcProxyListenCA, grpcProxyListenCert, grpcProxyListenKey)
|
||||||
if tlsinfo == nil && grpcProxyListenAutoTLS {
|
if tlsinfo == nil && grpcProxyListenAutoTLS {
|
||||||
host := []string{"https://" + grpcProxyListenAddr}
|
host := []string{"https://" + grpcProxyListenAddr}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user