From e66c4b11d5467780b8671b93b8383f8f5125f50a Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 10 Nov 2017 16:21:46 -0500 Subject: [PATCH] Add core numbers to output in dev three node --- command/server.go | 12 +++++++++++- vault/testing.go | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/command/server.go b/command/server.go index 63b73ed42..43d547a14 100644 --- a/command/server.go +++ b/command/server.go @@ -29,11 +29,13 @@ import ( "github.com/armon/go-metrics/circonus" "github.com/armon/go-metrics/datadog" "github.com/hashicorp/errwrap" + hclog "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-multierror" "github.com/hashicorp/vault/audit" "github.com/hashicorp/vault/command/server" "github.com/hashicorp/vault/helper/flag-slice" "github.com/hashicorp/vault/helper/gated-writer" + "github.com/hashicorp/vault/helper/logbridge" "github.com/hashicorp/vault/helper/logformat" "github.com/hashicorp/vault/helper/mlock" "github.com/hashicorp/vault/helper/parseutil" @@ -123,7 +125,14 @@ func (c *ServerCommand) Run(args []string) int { } switch strings.ToLower(logFormat) { case "vault", "vault_json", "vault-json", "vaultjson", "json", "": - c.logger = logformat.NewVaultLoggerWithWriter(c.logGate, level) + if devThreeNode { + c.logger = logbridge.NewLogger(hclog.New(&hclog.LoggerOptions{ + Mutex: &sync.Mutex{}, + Output: c.logGate, + })).LogxiLogger() + } else { + c.logger = logformat.NewVaultLoggerWithWriter(c.logGate, level) + } default: c.logger = log.NewLogger(c.logGate, "vault") c.logger.SetLevel(level) @@ -850,6 +859,7 @@ func (c *ServerCommand) enableThreeNodeDevCluster(base *vault.CoreConfig, info m testCluster := vault.NewTestCluster(&testing.RuntimeT{}, base, &vault.TestClusterOptions{ HandlerFunc: vaulthttp.Handler, BaseListenAddress: devListenAddress, + RawLogger: c.logger, }) defer c.cleanupGuard.Do(testCluster.Cleanup) diff --git a/vault/testing.go b/vault/testing.go index d267467d3..f8d73d46f 100644 --- a/vault/testing.go +++ b/vault/testing.go @@ -1120,8 +1120,11 @@ func NewTestCluster(t testing.T, base *CoreConfig, opts *TestClusterOptions) *Te } if opts != nil && opts.RawLogger != nil { - if hclogger, ok := opts.RawLogger.(*logbridge.Logger); ok { - coreConfig.Logger = hclogger.Named(fmt.Sprintf("core%d", i)).LogxiLogger() + switch opts.RawLogger.(type) { + case *logbridge.Logger: + coreConfig.Logger = opts.RawLogger.(*logbridge.Logger).Named(fmt.Sprintf("core%d", i)).LogxiLogger() + case *logbridge.LogxiLogger: + coreConfig.Logger = opts.RawLogger.(*logbridge.LogxiLogger).Named(fmt.Sprintf("core%d", i)) } }