fix: adjust dfget download log (#564)
* fix: adjust dfget download log Signed-off-by: zuozheng.hzz <zuozheng.hzz@alibaba-inc.com>
This commit is contained in:
parent
19fa991340
commit
cddd25e908
|
|
@ -107,8 +107,8 @@ func download(ctx context.Context, client daemonclient.DaemonClient, cfg *config
|
||||||
_ = pb.Close()
|
_ = pb.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
wLog.Infof("download from daemon success, length: %dByte cost: %dms", result.CompletedLength, time.Now().Sub(start).Milliseconds())
|
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 Byte\n", result.CompletedLength)
|
fmt.Printf("finish total length %d bytes\n", result.CompletedLength)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -174,8 +174,8 @@ func downloadFromSource(ctx context.Context, cfg *config.DfgetConfig, hdr map[st
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
wLog.Infof("download from source success, length: %dByte cost: %dms", written, time.Now().Sub(start).Milliseconds())
|
wLog.Infof("download from source success, length: %d bytes cost: %d ms", written, time.Now().Sub(start).Milliseconds())
|
||||||
fmt.Printf("finish total length %d Byte\n", written)
|
fmt.Printf("finish total length %d bytes\n", written)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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("--%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\n", version.GitVersion)
|
||||||
fmt.Printf("dfget version[%s] default peer ip[%s]\n", version.GitVersion, iputils.HostIP)
|
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
|
// do get file
|
||||||
|
var errInfo string
|
||||||
err := runDfget()
|
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)
|
logger.With("url", dfgetConfig.URL).Info(msg)
|
||||||
fmt.Println(msg)
|
fmt.Println(msg)
|
||||||
|
|
||||||
return errors.Wrapf(err, "download url[%s]", dfgetConfig.URL)
|
return errors.Wrapf(err, "download url: %s", dfgetConfig.URL)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue