agent: differentiate wan vs lan loggers in memberlist and serf (#7205)

This should be a helpful change until memberlist and serf can be
properly switched to native hclog.
pull/7225/head
R.B. Boyer 5 years ago committed by GitHub
parent dceb107325
commit 0ecb4538c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,9 +38,11 @@ func (c *Client) setupSerf(conf *serf.Config, ch chan serf.Event, path string) (
// can be streamed via the monitor endpoint // can be streamed via the monitor endpoint
serfLogger := c.logger. serfLogger := c.logger.
NamedIntercept(logging.Serf). NamedIntercept(logging.Serf).
NamedIntercept(logging.LAN).
StandardLoggerIntercept(&hclog.StandardLoggerOptions{InferLevels: true}) StandardLoggerIntercept(&hclog.StandardLoggerOptions{InferLevels: true})
memberlistLogger := c.logger. memberlistLogger := c.logger.
NamedIntercept(logging.Memberlist). NamedIntercept(logging.Memberlist).
NamedIntercept(logging.LAN).
StandardLoggerIntercept(&hclog.StandardLoggerOptions{InferLevels: true}) StandardLoggerIntercept(&hclog.StandardLoggerOptions{InferLevels: true})
conf.MemberlistConfig.Logger = memberlistLogger conf.MemberlistConfig.Logger = memberlistLogger

@ -80,14 +80,23 @@ func (s *Server) setupSerf(conf *serf.Config, ch chan serf.Event, path string, w
conf.Tags["acls"] = string(structs.ACLModeDisabled) conf.Tags["acls"] = string(structs.ACLModeDisabled)
} }
var subLoggerName string
if wan {
subLoggerName = logging.WAN
} else {
subLoggerName = logging.LAN
}
// Wrap hclog in a standard logger wrapper for serf and memberlist // Wrap hclog in a standard logger wrapper for serf and memberlist
// We use the Intercept variant here to ensure that serf and memberlist logs // We use the Intercept variant here to ensure that serf and memberlist logs
// can be streamed via the monitor endpoint // can be streamed via the monitor endpoint
serfLogger := s.logger. serfLogger := s.logger.
NamedIntercept(logging.Serf). NamedIntercept(logging.Serf).
NamedIntercept(subLoggerName).
StandardLoggerIntercept(&hclog.StandardLoggerOptions{InferLevels: true}) StandardLoggerIntercept(&hclog.StandardLoggerOptions{InferLevels: true})
memberlistLogger := s.logger. memberlistLogger := s.logger.
NamedIntercept(logging.Memberlist). NamedIntercept(logging.Memberlist).
NamedIntercept(subLoggerName).
StandardLoggerIntercept(&hclog.StandardLoggerOptions{InferLevels: true}) StandardLoggerIntercept(&hclog.StandardLoggerOptions{InferLevels: true})
conf.MemberlistConfig.Logger = memberlistLogger conf.MemberlistConfig.Logger = memberlistLogger

@ -23,6 +23,7 @@ const (
Intentions string = "intentions" Intentions string = "intentions"
Internal string = "internal" Internal string = "internal"
KV string = "kvs" KV string = "kvs"
LAN string = "lan"
Leader string = "leader" Leader string = "leader"
Legacy string = "legacy" Legacy string = "legacy"
License string = "license" License string = "license"
@ -44,5 +45,6 @@ const (
Snapshot string = "snapshot" Snapshot string = "snapshot"
TLSUtil string = "tlsutil" TLSUtil string = "tlsutil"
Transaction string = "txn" Transaction string = "txn"
WAN string = "wan"
Watch string = "watch" Watch string = "watch"
) )

Loading…
Cancel
Save