wrap log messages with hclog (#11291)

This commit is contained in:
Luiz Aoqui
2021-10-12 14:38:44 -04:00
committed by GitHub
parent 721f388f43
commit 713094ffb7
2 changed files with 9 additions and 1 deletions

View File

@@ -470,7 +470,6 @@ func SetupLoggers(ui cli.Ui, config *Config) (*logutils.LevelFilter, *gatedwrite
}
logOutput := io.MultiWriter(writers...)
log.SetOutput(logOutput)
return logFilter, logGate, logOutput
}
@@ -649,6 +648,12 @@ func (c *Command) Run(args []string) int {
JSONFormat: config.LogJson,
})
// Wrap log messages emitted with the 'log' package.
// These usually come from external dependencies.
log.SetOutput(logger.StandardWriter(&hclog.StandardLoggerOptions{InferLevels: true}))
log.SetPrefix("")
log.SetFlags(0)
// Swap out UI implementation if json logging is enabled
if config.LogJson {
c.Ui = &logging.HcLogUI{Log: logger}