diff --git a/cmd/cmd.go b/cmd/cmd.go index 8d80ab80e..d40d35766 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -8,6 +8,7 @@ import ( "net/http" "net/http/pprof" "os" + "path/filepath" "sync" "sync/atomic" "time" @@ -46,7 +47,7 @@ const ( ) func timestampLogFileName() string { - return filepath.Join(os.TempDir(), "br-" + time.Now().Format(time.RFC3339)) + return filepath.Join(os.TempDir(), "br-"+time.Now().Format(time.RFC3339)) } // AddFlags adds flags to the given cmd. @@ -82,10 +83,10 @@ func Init(cmd *cobra.Command) (err error) { } if len(conf.File.Filename) != 0 { atomic.StoreUint64(&hasLogFile, 1) + summary.InitCollector(true) } else { fmt.Printf("log file: %s\n", conf.File.Filename) } - summary.InitCollector(bool(hasLogFile)) lg, p, e := log.InitLogger(conf) if e != nil { err = e diff --git a/pkg/task/backup.go b/pkg/task/backup.go index 529fd071e..8d9613047 100644 --- a/pkg/task/backup.go +++ b/pkg/task/backup.go @@ -214,7 +214,6 @@ func RunBackup(c context.Context, g glue.Glue, cmdName string, cfg *BackupConfig err = client.SaveBackupMeta(ctx, ddlJobs) if err != nil { - log.Error("save backup meta failed", zap.Reflect("meta", ddlJobs)) return err } return nil diff --git a/pkg/task/common.go b/pkg/task/common.go index 3785c2928..859c4206d 100644 --- a/pkg/task/common.go +++ b/pkg/task/common.go @@ -12,14 +12,12 @@ import ( "github.com/gogo/protobuf/proto" "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/backup" - "github.com/pingcap/log" pd "github.com/pingcap/pd/v4/client" "github.com/pingcap/tidb-tools/pkg/filter" "github.com/pingcap/tidb/store/tikv" "github.com/spf13/cobra" "github.com/spf13/pflag" "go.etcd.io/etcd/pkg/transport" - "go.uber.org/zap" "github.com/pingcap/br/pkg/conn" "github.com/pingcap/br/pkg/glue" @@ -276,7 +274,6 @@ func ReadBackupMeta( } backupMeta := &backup.BackupMeta{} if err = proto.Unmarshal(metaData, backupMeta); err != nil { - log.Error("parse backupmeta failed", zap.Error(err), zap.Binary("meta", metaData)) return nil, nil, nil, errors.Annotate(err, "parse backupmeta failed") } return u, s, backupMeta, nil diff --git a/pkg/task/restore.go b/pkg/task/restore.go index 5ca00f693..8b5e26199 100644 --- a/pkg/task/restore.go +++ b/pkg/task/restore.go @@ -104,12 +104,6 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf return err } - defer func() { - if err != nil { - log.Error("restore failed", zap.Error(err), zap.Reflect("meta", backupMeta)) - } - }() - if err = client.InitBackupMeta(backupMeta, u); err != nil { return err }