Skip to content

Commit

Permalink
Condensed Duplicate logger output
Browse files Browse the repository at this point in the history
Resolves #1245

Explicitly spell out empty data directory as well as condensed error
messages when running conduit
  • Loading branch information
AlgoStephenAkiki committed Oct 3, 2022
1 parent a6b7473 commit c6dcff6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/conduit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func makeConduitCmd() *cobra.Command {
return runConduitCmdWithConfig(cfg)
},
SilenceUsage: true,
// Silence errors because our logger will catch and print any errors
SilenceErrors: true,
}

cfg.Flags = cmd.Flags()
Expand Down Expand Up @@ -183,7 +185,7 @@ func makeInitCmd() *cobra.Command {

func main() {
if err := conduitCmd.Execute(); err != nil {
log.Errorf("%v", err)
logger.Errorf("%v", err)
os.Exit(1)
}

Expand Down
10 changes: 9 additions & 1 deletion conduit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ type Config struct {

func (cfg *Config) String() string {
var sb strings.Builder
fmt.Fprintf(&sb, "Data Directory: %s ", cfg.ConduitDataDir)

var dataDirToPrint string
if cfg.ConduitDataDir == "" {
dataDirToPrint = "[EMPTY]"
} else {
dataDirToPrint = cfg.ConduitDataDir
}

fmt.Fprintf(&sb, "Data Directory: %s ", dataDirToPrint)

return sb.String()
}
Expand Down

0 comments on commit c6dcff6

Please sign in to comment.