From 1139d7361ee1c58b515d9d68cc32ccb3471ab9b8 Mon Sep 17 00:00:00 2001 From: kenriortega Date: Thu, 11 Nov 2021 09:56:36 -0500 Subject: [PATCH] ref: change log format --- cmd/cli/root.go | 9 +++++---- pkg/errors/customsErrors.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/cli/root.go b/cmd/cli/root.go index 7136c48..7b9dbd2 100644 --- a/cmd/cli/root.go +++ b/cmd/cli/root.go @@ -13,6 +13,7 @@ import ( handlers "github.com/kenriortega/ngonx/internal/mngt/handlers" services "github.com/kenriortega/ngonx/internal/mngt/services" "github.com/kenriortega/ngonx/pkg/config" + "github.com/kenriortega/ngonx/pkg/errors" "github.com/kenriortega/ngonx/pkg/healthcheck" "github.com/kenriortega/ngonx/pkg/httpsrv" "github.com/kenriortega/ngonx/pkg/logger" @@ -70,7 +71,7 @@ func initConfig() { configFromYaml, errConfig = config.LoadConfig(cfgPath, cfgFile) if errConfig != nil { - logger.LogError("Yaml file not found please run command setup " + errConfig.Error()) + logger.LogError(errors.Errorf("ngonx: Yaml file not found please run command setup :%v", errConfig).Error()) } go StartMngt(configFromYaml) @@ -80,7 +81,7 @@ func StartMngt(config config.Config) { stripped, err := fs.Sub(frontend, "ui") if err != nil { - logger.LogError(err.Error()) + logger.LogError(errors.Errorf("ngonx: :%v", err).Error()) } frontendFS := http.FileServer(http.FS(stripped)) @@ -125,12 +126,12 @@ func StartMngt(config config.Config) { endpoints, err := service.ListEndpoints() if err != nil { - logger.LogError(err.Error()) + logger.LogError(errors.Errorf("ngonx: :%v", err).Error()) } for _, it := range endpoints { u, err := url.Parse(it.PathUrl) if err != nil { - logger.LogError(err.Error()) + logger.LogError(errors.Errorf("ngonx: :%v", err).Error()) } status := healthcheck.IsBackendAlive(u) if status { diff --git a/pkg/errors/customsErrors.go b/pkg/errors/customsErrors.go index f8fbb28..bc12d30 100644 --- a/pkg/errors/customsErrors.go +++ b/pkg/errors/customsErrors.go @@ -9,7 +9,7 @@ var ( ErrCreatingSettingFile = NewError("security: error on create setting file") ErrWritingSettingFile = NewError("security: error on write setting file") // loadbalancer - ErrIsBackendAlive = NewError("lb: Site unreachcable dial tcp") + ErrIsBackendAlive = NewError("ngonx healthcheck: Site unreachcable dial tcp") // repositoryDB ErrSavekeyUpdateTX = NewError("badgerdb: error executing TX to save apikey") ErrSavekeyUpdate = NewError("badgerdb: error to save apikey") @@ -19,7 +19,7 @@ var ( ErrGetkeyValue = NewError("baderdb: error executing get item value") ErrGetkeyView = NewError("baderdb: error executing get view") // lbHandler - ErrLBHttp = NewError("lbHandler: error service not availeble") + ErrLBHttp = NewError("lb: error service not availeble") ErrBearerTokenFormat = NewError("proxyHandler: error Format is Authorization: Bearer [token]") ErrTokenExpValidation = NewError("proxyHandler: error token expired") ErrTokenHMACValidation = NewError("proxyHandler: error HMAC verification failed")