Skip to content

Commit

Permalink
fix: adjust dfget download log (#564)
Browse files Browse the repository at this point in the history
* fix: adjust dfget download log

Signed-off-by: zuozheng.hzz <zuozheng.hzz@alibaba-inc.com>
  • Loading branch information
garfield009 committed Aug 19, 2021
1 parent dddf241 commit dfb7f1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions client/dfget/dfget.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func download(ctx context.Context, client daemonclient.DaemonClient, cfg *config
_ = pb.Close()
}

wLog.Infof("download from daemon success, length: %dByte cost: %dms", result.CompletedLength, time.Now().Sub(start).Milliseconds())
fmt.Printf("finish total length %d Byte\n", result.CompletedLength)
wLog.Infof("download from daemon success, length: %d bytes cost: %d ms", result.CompletedLength, time.Now().Sub(start).Milliseconds())
fmt.Printf("finish total length %d bytes\n", result.CompletedLength)

break
}
Expand Down Expand Up @@ -174,8 +174,8 @@ func downloadFromSource(ctx context.Context, cfg *config.DfgetConfig, hdr map[st
return err
}

wLog.Infof("download from source success, length: %dByte cost: %dms", written, time.Now().Sub(start).Milliseconds())
fmt.Printf("finish total length %d Byte\n", written)
wLog.Infof("download from source success, length: %d bytes cost: %d ms", written, time.Now().Sub(start).Milliseconds())
fmt.Printf("finish total length %d bytes\n", written)

return nil
}
Expand Down
13 changes: 9 additions & 4 deletions cmd/dfget/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,22 @@ var rootCmd = &cobra.Command{
}

fmt.Printf("--%s-- %s\n", start.Format("2006-01-02 15:04:05"), dfgetConfig.URL)
fmt.Printf("current user[%s] output path[%s]\n", basic.Username, dfgetConfig.Output)
fmt.Printf("dfget version[%s] default peer ip[%s]\n", version.GitVersion, iputils.HostIP)
fmt.Printf("dfget version: %s\n", version.GitVersion)
fmt.Printf("current user: %s, default peer ip: %s\n", basic.Username, iputils.HostIP)
fmt.Printf("output path: %s\n", dfgetConfig.Output)

// do get file
var errInfo string
err := runDfget()
if err != nil {
errInfo = fmt.Sprintf("error: %v", err)
}

msg := fmt.Sprintf("download success: %t cost: %dms error:[%v]", err == nil, time.Now().Sub(start).Milliseconds(), err)
msg := fmt.Sprintf("download success: %t cost: %d ms %s", err == nil, time.Now().Sub(start).Milliseconds(), errInfo)
logger.With("url", dfgetConfig.URL).Info(msg)
fmt.Println(msg)

return errors.Wrapf(err, "download url[%s]", dfgetConfig.URL)
return errors.Wrapf(err, "download url: %s", dfgetConfig.URL)
},
}

Expand Down

0 comments on commit dfb7f1e

Please sign in to comment.