Skip to content

Commit

Permalink
Use zap logger for all logs
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Mar 13, 2024
1 parent 4386273 commit e9efc86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
6 changes: 4 additions & 2 deletions cmd/merge-nodes/internal/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import (
"errors"
)

var ErrSupervisedNode = errors.New("merging of supervised smeshing nodes is not supported")
var ErrInvalidSchema = errors.New("database has an invalid schema version")
var (
ErrSupervisedNode = errors.New("merging of supervised smeshing nodes is not supported")
ErrInvalidSchema = errors.New("database has an invalid schema version")
)
20 changes: 11 additions & 9 deletions cmd/merge-nodes/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"log"
"os"

Expand All @@ -14,6 +13,14 @@ import (
var version string

func main() {
cfg := zap.NewProductionConfig()
cfg.Encoding = "console"
dbLog, err := cfg.Build()
if err != nil {
log.Fatalln("create logger:", err)
}
defer dbLog.Sync()

app := &cli.App{
Name: "Spacemesh Node Merger",
Usage: "Merge identities of two Spacemesh nodes into one.\n" +
Expand All @@ -38,18 +45,13 @@ func main() {
},
},
Action: func(ctx *cli.Context) error {
cfg := zap.NewProductionConfig()
cfg.Encoding = "console"
dbLog, err := cfg.Build()
if err != nil {
return fmt.Errorf("create logger: %w", err)
}
defer dbLog.Sync()
return internal.MergeDBs(ctx.Context, dbLog, ctx.String("from"), ctx.String("to"))
},
}

if err := app.Run(os.Args); err != nil {
log.Fatalf("app run: %v\n", err)
dbLog.Fatal("app run:",
zap.Error(err),
)
}
}

0 comments on commit e9efc86

Please sign in to comment.