Skip to content

Commit

Permalink
feat: replace logrus with zap (#1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeMac committed Sep 12, 2022
1 parent ce4354a commit bd44dd9
Show file tree
Hide file tree
Showing 22 changed files with 658 additions and 534 deletions.
5 changes: 3 additions & 2 deletions cmd/flipt/export.go
Expand Up @@ -15,11 +15,12 @@ import (
"go.flipt.io/flipt/storage/sql/mysql"
"go.flipt.io/flipt/storage/sql/postgres"
"go.flipt.io/flipt/storage/sql/sqlite"
"go.uber.org/zap"
)

var exportFilename string

func runExport(ctx context.Context) error {
func runExport(ctx context.Context, logger *zap.Logger) error {
ctx, cancel := context.WithCancel(ctx)

defer cancel()
Expand Down Expand Up @@ -55,7 +56,7 @@ func runExport(ctx context.Context) error {

// export to file
if exportFilename != "" {
l.Debugf("exporting to %q", exportFilename)
logger.Debug("exporting", zap.String("destination_path", exportFilename))

out, err = os.Create(exportFilename)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions cmd/flipt/import.go
Expand Up @@ -16,14 +16,15 @@ import (
"go.flipt.io/flipt/storage/sql/mysql"
"go.flipt.io/flipt/storage/sql/postgres"
"go.flipt.io/flipt/storage/sql/sqlite"
"go.uber.org/zap"
)

var (
dropBeforeImport bool
importStdin bool
)

func runImport(ctx context.Context, args []string) error {
func runImport(ctx context.Context, logger *zap.Logger, args []string) error {
ctx, cancel := context.WithCancel(ctx)

defer cancel()
Expand Down Expand Up @@ -64,7 +65,7 @@ func runImport(ctx context.Context, args []string) error {

f := filepath.Clean(importFilename)

l.Debugf("importing from %q", f)
logger.Debug("importing", zap.String("source_path", f))

in, err = os.Open(f)
if err != nil {
Expand All @@ -76,7 +77,7 @@ func runImport(ctx context.Context, args []string) error {

// drop tables if specified
if dropBeforeImport {
l.Debug("dropping tables before import")
logger.Debug("dropping tables before import")

tables := []string{"schema_migrations", "distributions", "rules", "constraints", "variants", "segments", "flags"}

Expand All @@ -87,7 +88,7 @@ func runImport(ctx context.Context, args []string) error {
}
}

migrator, err := sql.NewMigrator(*cfg, l)
migrator, err := sql.NewMigrator(*cfg, logger)
if err != nil {
return err
}
Expand Down

0 comments on commit bd44dd9

Please sign in to comment.