From 36e8461b4cac6a18e8ad2d6e104dfc0855fda24e Mon Sep 17 00:00:00 2001 From: Derek Su Date: Wed, 16 Nov 2022 20:54:51 +0800 Subject: [PATCH] Unify fatal log messages Longhorn 4210 Longhorn 3198 Signed-off-by: Derek Su --- app/cmd/process.go | 10 +++++----- app/cmd/start.go | 2 +- app/cmd/version.go | 2 +- main.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/cmd/process.go b/app/cmd/process.go index 947bfe3cd..eb2f767c6 100644 --- a/app/cmd/process.go +++ b/app/cmd/process.go @@ -44,7 +44,7 @@ func ProcessCreateCmd() cli.Command { }, Action: func(c *cli.Context) { if err := createProcess(c); err != nil { - logrus.Fatalf("Error running process create command: %v.", err) + logrus.WithError(err).Fatal("Error running process create command") } }, } @@ -75,7 +75,7 @@ func ProcessDeleteCmd() cli.Command { }, Action: func(c *cli.Context) { if err := deleteProcess(c); err != nil { - logrus.Fatalf("Error running process delete command: %v.", err) + logrus.WithError(err).Fatal("Error running process delete command") } }, } @@ -105,7 +105,7 @@ func ProcessGetCmd() cli.Command { }, Action: func(c *cli.Context) { if err := getProcess(c); err != nil { - logrus.Fatalf("Error running process get command: %v.", err) + logrus.WithError(err).Fatal("Error running process get command") } }, } @@ -131,7 +131,7 @@ func ProcessListCmd() cli.Command { ShortName: "ls", Action: func(c *cli.Context) { if err := listProcess(c); err != nil { - logrus.Fatalf("Error running engine stop command: %v.", err) + logrus.WithError(err).Fatal("Error running engine stop command") } }, } @@ -176,7 +176,7 @@ func ProcessReplaceCmd() cli.Command { }, Action: func(c *cli.Context) { if err := replaceProcess(c); err != nil { - logrus.Fatalf("Error running engine replace command: %v.", err) + logrus.WithError(err).Fatal("Error running engine replace command") } }, } diff --git a/app/cmd/start.go b/app/cmd/start.go index fd7336365..c28f273f1 100644 --- a/app/cmd/start.go +++ b/app/cmd/start.go @@ -46,7 +46,7 @@ func StartCmd() cli.Command { }, Action: func(c *cli.Context) { if err := start(c); err != nil { - logrus.Fatalf("Failed to run start command: %v.", err) + logrus.WithError(err).Fatal("Failed to run start command") } }, } diff --git a/app/cmd/version.go b/app/cmd/version.go index fc58e06c7..8ff2feb6d 100644 --- a/app/cmd/version.go +++ b/app/cmd/version.go @@ -20,7 +20,7 @@ func VersionCmd() cli.Command { }, Action: func(c *cli.Context) { if err := version(c); err != nil { - logrus.Fatalln("Error running info command:", err) + logrus.WithError(err).Fatal("Error running info command") } }, } diff --git a/main.go b/main.go index 4d6556adc..3feb2b099 100644 --- a/main.go +++ b/main.go @@ -53,6 +53,6 @@ func main() { cmd.VersionCmd(), } if err := a.Run(os.Args); err != nil { - logrus.Fatal("Error when executing command: ", err) + logrus.WithError(err).Fatal("Error when executing command") } }