Switch output loggers in hclog instead of going through gatedlogger (#8228)

After flushing we no longer have to take a mutex hit for every log line.
This commit is contained in:
Jeff Mitchell
2020-02-14 20:50:47 -05:00
committed by GitHub
parent 16210db724
commit 4bf92f2617
2 changed files with 29 additions and 18 deletions

View File

@@ -223,9 +223,9 @@ func (c *DebugCommand) Run(args []string) int {
}
// Initialize the logger for debug output
logWriter := gatedwriter.NewWriter(os.Stderr)
gatedWriter := gatedwriter.NewWriter(os.Stderr)
if c.logger == nil {
c.logger = logging.NewVaultLoggerWithWriter(logWriter, hclog.Trace)
c.logger = logging.NewVaultLoggerWithWriter(gatedWriter, hclog.Trace)
}
dstOutputFile, err := c.preflight(args)
@@ -246,7 +246,9 @@ func (c *DebugCommand) Run(args []string) int {
c.UI.Output("")
// Release the log gate.
logWriter.Flush()
c.logger.(hclog.OutputResettable).ResetOutputWithFlush(&hclog.LoggerOptions{
Output: os.Stderr,
}, gatedWriter)
// Capture static information
c.UI.Info("==> Capturing static information...")