From c531b747dc9caf1a30f91e10c411ffd29f9ae491 Mon Sep 17 00:00:00 2001 From: Ahmad Malik Ibrahim Date: Tue, 18 Jun 2024 14:58:57 -0700 Subject: [PATCH] chore: remove logging to disk (#30) --- pkg/cmd/common/common.go | 4 ---- pkg/config/constants.go | 4 ++-- pkg/logging/logger.go | 24 +++--------------------- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/pkg/cmd/common/common.go b/pkg/cmd/common/common.go index 29a84b98..f486268e 100644 --- a/pkg/cmd/common/common.go +++ b/pkg/cmd/common/common.go @@ -4,7 +4,6 @@ import ( "fmt" cfg "github.com/validator-labs/validatorctl/pkg/config" - log "github.com/validator-labs/validatorctl/pkg/logging" embed_utils "github.com/validator-labs/validatorctl/pkg/utils/embed" ) @@ -17,8 +16,5 @@ func InitWorkspace(c *cfg.Config, workspaceDir string, subdirs []string, timesta // Unpack binaries embed_utils.InitBinaries(c) - // Initialize logger - log.SetOutput(c.RunLoc) - return nil } diff --git a/pkg/config/constants.go b/pkg/config/constants.go index e959a47c..3398ccbe 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -84,8 +84,8 @@ var ( HTTPSchemes = []string{"https://", "http://"} // Command dirs - BaseDirs = []string{"bin", "logs"} - ValidatorSubdirs = []string{"logs", "manifests"} + BaseDirs = []string{"bin"} + ValidatorSubdirs = []string{"manifests"} // Validator PlacementTypeStatic = "Static" diff --git a/pkg/logging/logger.go b/pkg/logging/logger.go index dab942aa..604bb96a 100644 --- a/pkg/logging/logger.go +++ b/pkg/logging/logger.go @@ -5,7 +5,6 @@ import ( "io" logging "log" "os" - "path/filepath" "runtime" "strings" @@ -13,19 +12,13 @@ import ( "github.com/sirupsen/logrus" ) -// The global logger's standard methods (i.e., log.Infof, log.Debugf, etc.) -// write log entries to disk. -// -// file location: ~/.validator/logs/validator.log -// // The log.InfoCLI method logs entries to the console. It is used to guide users // through an interactive TUI experience. var ( - log *logrus.Logger - cliLog = pterm.DefaultLogger - logFile, statusFile string - Newline = true + log *logrus.Logger + cliLog = pterm.DefaultLogger + Newline = true ) func init() { @@ -45,17 +38,6 @@ func SetLevel(logLevel string) { log.SetLevel(level) } -func SetOutput(runLoc string) { - logFile = filepath.Join(runLoc, "logs", "validator.log") - statusFile = filepath.Join(runLoc, "status", "status") - - f, err := os.OpenFile(logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600) //#nosec - if err != nil { - logging.Fatalf("error opening file: %v", err) - } - log.SetOutput(f) -} - // logContext recovers the original caller context of each log message func logContext() *logrus.Entry { if pc, file, line, ok := runtime.Caller(2); ok {