Skip to content

Commit

Permalink
chore: remove logging to disk (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-ibra authored Jun 18, 2024
1 parent c5e83cc commit c531b74
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
4 changes: 0 additions & 4 deletions pkg/cmd/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
}
4 changes: 2 additions & 2 deletions pkg/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 3 additions & 21 deletions pkg/logging/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,20 @@ import (
"io"
logging "log"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/pterm/pterm"
"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() {
Expand All @@ -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 {
Expand Down

0 comments on commit c531b74

Please sign in to comment.