mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
wrap log messages with hclog (#11291)
This commit is contained in:
3
.changelog/11291.txt
Normal file
3
.changelog/11291.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
agent: Fixed an issue that caused some non-JSON log output when `log_json` was enabled
|
||||
```
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user