cmd/{storagenode,storagenode-updater}: add Process name to logs
Now that we have both the storagenode and updater processes running in a single docker container, we need a way to know which log entry is logged by any of the processes. This change includes a Process field in the log entries. Resolves https://github.com/storj/storj/issues/4648 Change-Id: I167b9ab65728a41136d264b5fe2c41bb64ed1785
This commit is contained in:
parent
623cb16b6e
commit
e9611801ad
@ -152,6 +152,6 @@ func openLog(logPath string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
zap.ReplaceGlobals(logger)
|
zap.ReplaceGlobals(logger.With(zap.String("Process", updaterServiceName)))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -104,10 +104,10 @@ func TestAutoUpdater(t *testing.T) {
|
|||||||
if assert.NoError(t, logErr) {
|
if assert.NoError(t, logErr) {
|
||||||
logStr := string(logData)
|
logStr := string(logData)
|
||||||
t.Log(logStr)
|
t.Log(logStr)
|
||||||
if !assert.Contains(t, logStr, `Service restarted successfully. {"Service": "storagenode"}`) {
|
if !assert.Contains(t, logStr, `Service restarted successfully. {"Process": "storagenode-updater", "Service": "storagenode"}`) {
|
||||||
t.Log(logStr)
|
t.Log(logStr)
|
||||||
}
|
}
|
||||||
if !assert.Contains(t, logStr, `Service restarted successfully. {"Service": "storagenode-updater"}`) {
|
if !assert.Contains(t, logStr, `Service restarted successfully. {"Process": "storagenode-updater", "Service": "storagenode-updater"}`) {
|
||||||
t.Log(logStr)
|
t.Log(logStr)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,8 +6,16 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "storj.io/private/process"
|
import (
|
||||||
|
"go.uber.org/zap"
|
||||||
|
|
||||||
|
"storj.io/private/process"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
process.Exec(rootCmd)
|
loggerFunc := func(logger *zap.Logger) *zap.Logger {
|
||||||
|
return logger.With(zap.String("Process", updaterServiceName))
|
||||||
|
}
|
||||||
|
|
||||||
|
process.ExecWithCustomConfigAndLogger(rootCmd, true, process.LoadConfig, loggerFunc)
|
||||||
}
|
}
|
||||||
|
@ -471,5 +471,10 @@ func main() {
|
|||||||
if startAsService() {
|
if startAsService() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
process.ExecCustomDebug(rootCmd)
|
|
||||||
|
loggerFunc := func(logger *zap.Logger) *zap.Logger {
|
||||||
|
return logger.With(zap.String("Process", rootCmd.Use))
|
||||||
|
}
|
||||||
|
|
||||||
|
process.ExecWithCustomConfigAndLogger(rootCmd, false, process.LoadConfig, loggerFunc)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user