Skip to content

Commit

Permalink
use stdout on update and verbose information (#1551)
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar authored Sep 6, 2021
1 parent 562140c commit abd147a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/exec/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func RunComponent(env *environment.Environment, tag, spec, binPath string, args
}
}
if err != nil {
fmt.Printf("Failed to start component `%s`\n", component)
fmt.Fprintf(os.Stderr, "Failed to start component `%s`\n", component)
return err
}

Expand All @@ -77,7 +77,7 @@ func RunComponent(env *environment.Environment, tag, spec, binPath string, args
(sig == syscall.SIGINT && strings.Contains(errs, "exit status 1")) {
continue
}
fmt.Printf("Component `%s` exit with error: %s\n", component, errs)
fmt.Fprintf(os.Stderr, "Component `%s` exit with error: %s\n", component, errs)
return
}
}
Expand Down Expand Up @@ -120,7 +120,7 @@ Found %[1]s newer version:
select {
case s := <-sc:
sig = s.(syscall.Signal)
fmt.Printf("Got signal %v (Component: %v ; PID: %v)\n", s, component, p.Pid)
fmt.Fprintf(os.Stderr, "Got signal %v (Component: %v ; PID: %v)\n", s, component, p.Pid)
if component == "tidb" {
return syscall.Kill(p.Pid, syscall.SIGKILL)
}
Expand All @@ -130,7 +130,7 @@ Found %[1]s newer version:
return nil

case err := <-ch:
defer fmt.Print(<-updateC)
defer fmt.Fprint(os.Stderr, <-updateC)
return errors.Annotatef(err, "run `%s` (wd:%s) failed", p.Exec, p.Dir)
}
}
Expand All @@ -140,7 +140,7 @@ func cleanDataDir(rm bool, dir string) {
return
}
if err := os.RemoveAll(dir); err != nil {
fmt.Println("clean data directory failed: ", err.Error())
fmt.Fprintln(os.Stderr, "clean data directory failed: ", err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/logger/log/verbose.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ func Verbose(format string, args ...interface{}) {
if !verbose {
return
}
fmt.Println("Verbose:", fmt.Sprintf(format, args...))
fmt.Fprintln(os.Stderr, "Verbose:", fmt.Sprintf(format, args...))
}

1 comment on commit abd147a

@nexustar
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong commit message, should be "use stderr on update and verbose information "

Please sign in to comment.