diff --git a/pkg/daemon/handler/ssh.go b/pkg/daemon/handler/ssh.go index 93b12e8d..f01dde91 100644 --- a/pkg/daemon/handler/ssh.go +++ b/pkg/daemon/handler/ssh.go @@ -246,7 +246,7 @@ func (w *wsHandler) remoteInstallKubevpnIfCommandNotFound(ctx context.Context, s w.Log("Get latest kubevpn version failed: %v", err) return err } - fmt.Printf("The latest version is: %s, commit: %s\n", latestVersion, latestCommit) + w.Log("The latest version is: %s, commit: %s", latestVersion, latestCommit) var temp *os.File temp, err = os.CreateTemp("", "") if err != nil { @@ -304,6 +304,7 @@ func (w *wsHandler) Log(format string, a ...any) { str = fmt.Sprintf(format, a...) } w.conn.Write([]byte(str + "\r\n")) + log.Infof(format, a...) } func (w *wsHandler) PrintLine(msg string) { diff --git a/pkg/util/scp.go b/pkg/util/scp.go index 2098239e..29cc28d4 100644 --- a/pkg/util/scp.go +++ b/pkg/util/scp.go @@ -72,7 +72,9 @@ func main(sess *ssh.Session, stdout, stderr io.Writer, filename string, to strin func sCopy(dst io.Writer, src io.Reader, size int64, stdout, stderr io.Writer) error { total := float64(size) / 1024 / 1024 - log.Printf("Length: 68276642 (%0.2fM)\n", total) + s := fmt.Sprintf("Length: %d (%0.2fM)\n", size, total) + log.Info(s) + io.WriteString(stdout, s) bar := progressbar.NewOptions(int(size), progressbar.OptionSetWriter(stdout), diff --git a/pkg/util/upgarde.go b/pkg/util/upgarde.go index 9a00c28f..8f2bbc11 100644 --- a/pkg/util/upgarde.go +++ b/pkg/util/upgarde.go @@ -11,6 +11,7 @@ import ( "strings" "github.com/schollz/progressbar/v3" + log "github.com/sirupsen/logrus" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/sets" ) @@ -88,7 +89,9 @@ func Download(client *http.Client, url string, filename string, stdout, stderr i } defer get.Body.Close() total := float64(get.ContentLength) / 1024 / 1024 - fmt.Printf("Length: 68276642 (%0.2fM)\n", total) + s := fmt.Sprintf("Length: %d (%0.2fM)\n", get.ContentLength, total) + log.Info(s) + io.WriteString(stdout, s) var f *os.File f, err = os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)