From a87f8288448223225371946c974b3404a69b9a9f Mon Sep 17 00:00:00 2001 From: mlsmaycon Date: Tue, 22 Jun 2021 01:07:12 +0200 Subject: [PATCH] Adjust service command outputs to use cmd Print functions --- cmd/service_controller.go | 29 ++++++++++++++++++++--------- cmd/service_installer.go | 15 ++++++++++----- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/cmd/service_controller.go b/cmd/service_controller.go index e47ba493f9a..a02a554b89f 100644 --- a/cmd/service_controller.go +++ b/cmd/service_controller.go @@ -2,7 +2,6 @@ package cmd import ( "github.com/kardianos/service" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -31,12 +30,15 @@ var ( s, err := newSVC(prg, newSVCConfig()) if err != nil { - log.Fatal(err) + cmd.PrintErrln(err) + return } err = s.Run() if err != nil { - logger.Error(err) //nolint + cmd.PrintErrln(err) + return } + cmd.Printf("Wiretrustee service is running") }, } ) @@ -49,12 +51,15 @@ var ( s, err := newSVC(&program{}, newSVCConfig()) if err != nil { - log.Fatal(err) + cmd.PrintErrln(err) + return } err = s.Start() if err != nil { - logger.Error(err) //nolint + cmd.PrintErrln(err) + return } + cmd.Printf("Wiretrustee service has been started") }, } ) @@ -67,12 +72,15 @@ var ( s, err := newSVC(&program{}, newSVCConfig()) if err != nil { - log.Fatal(err) + cmd.PrintErrln(err) + return } err = s.Stop() if err != nil { - logger.Error(err) //nolint + cmd.PrintErrln(err) + return } + cmd.Printf("Wiretrustee service has been stopped") }, } ) @@ -85,12 +93,15 @@ var ( s, err := newSVC(&program{}, newSVCConfig()) if err != nil { - log.Fatal(err) + cmd.PrintErrln(err) + return } err = s.Restart() if err != nil { - logger.Error(err) //nolint + cmd.PrintErrln(err) + return } + cmd.Printf("Wiretrustee service has been restarted") }, } ) diff --git a/cmd/service_installer.go b/cmd/service_installer.go index b5a2aaf86ea..1f289f81dd8 100644 --- a/cmd/service_installer.go +++ b/cmd/service_installer.go @@ -1,7 +1,6 @@ package cmd import ( - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "runtime" ) @@ -30,13 +29,16 @@ var ( s, err := newSVC(&program{}, svcConfig) if err != nil { - log.Fatal(err) + cmd.PrintErrln(err) + return } err = s.Install() if err != nil { - log.Error(err) + cmd.PrintErrln(err) + return } + cmd.Printf("Wiretrustee service has been installed") }, } ) @@ -49,13 +51,16 @@ var ( s, err := newSVC(&program{}, newSVCConfig()) if err != nil { - log.Fatal(err) + cmd.PrintErrln(err) + return } err = s.Uninstall() if err != nil { - log.Error(err) + cmd.PrintErrln(err) + return } + cmd.Printf("Wiretrustee has been uninstalled") }, } )