Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace logrus with zap #1020

Merged
merged 3 commits into from Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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