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

fix: adjust dfget download log #564

Merged
merged 3 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 cost: %d", result.CompletedLength, time.Now().Sub(start).Milliseconds())
fmt.Printf("finish total length %dbytes\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 cost: %d", written, time.Now().Sub(start).Milliseconds())
fmt.Printf("finish total length %dbytes\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()
gaius-qi marked this conversation as resolved.
Show resolved Hide resolved
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: %dms %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