Use utils.Debugf instead of log.*

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2014-06-06 10:47:13 -07:00 committed by Solomon Hykes
parent 50fdeb063c
commit 9e034af324
2 changed files with 12 additions and 13 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/dotcloud/docker/utils"
"io"
"io/ioutil"
"log"
"net"
"net/http"
"net/http/httputil"
@ -238,33 +237,33 @@ func (c *client) hijack(method, path string, in io.ReadCloser, stdout, stderr io
}
}()
_, err = utils.StdCopy(stdout, stderr, br)
log.Println("[hijack] End of stdout")
utils.Debugf("[hijack] End of stdout")
return err
})
sendStdin := utils.Go(func() error {
if in != nil {
io.Copy(rwc, in)
log.Println("[hijack] End of stdin")
utils.Debugf("[hijack] End of stdin")
}
if tcpc, ok := rwc.(*net.TCPConn); ok {
if err := tcpc.CloseWrite(); err != nil {
log.Printf("Couldn't send EOF: %s\n", err)
utils.Debugf("Couldn't send EOF: %s", err)
}
} else if unixc, ok := rwc.(*net.UnixConn); ok {
if err := unixc.CloseWrite(); err != nil {
log.Printf("Couldn't send EOF: %s\n", err)
utils.Debugf("Couldn't send EOF: %s", err)
}
}
// Discard errors due to pipe interruption
return nil
})
if err := <-receiveStdout; err != nil {
log.Printf("Error receiveStdout: %s\n", err)
utils.Debugf("Error receiveStdout: %s", err)
return err
}
if err := <-sendStdin; err != nil {
log.Printf("Error sendStdin: %s\n", err)
utils.Debugf("Error sendStdin: %s", err)
return err
}
return nil

View File

@ -7,8 +7,8 @@ import (
"github.com/docker/libswarm/backends"
"github.com/docker/libswarm/beam"
"github.com/dotcloud/docker/runconfig"
"github.com/dotcloud/docker/utils"
"io"
"log"
"os"
"strings"
)
@ -28,7 +28,7 @@ func main() {
func cmdDaemon(c *cli.Context) {
app := beam.NewServer()
app.OnLog(beam.Handler(func(msg *beam.Message) error {
log.Printf("%s\n", strings.Join(msg.Args, " "))
utils.Debugf("%s", strings.Join(msg.Args, " "))
return nil
}))
app.OnError(beam.Handler(func(msg *beam.Message) error {
@ -43,13 +43,13 @@ func cmdDaemon(c *cli.Context) {
dockerHost = "unix:///var/run/docker.sock"
}
log.Printf("---> Spawning\n")
utils.Debugf("---> Spawning")
instance, err := backend.Spawn(dockerHost)
if err != nil {
Fatalf("spawn: %v\n", err)
}
log.Printf("---> Attaching\n")
utils.Debugf("---> Attaching")
instanceIn, instanceOut, err := instance.Attach("")
if err != nil {
Fatalf("attach: %v", err)
@ -57,7 +57,7 @@ func cmdDaemon(c *cli.Context) {
defer instanceOut.Close()
go beam.Copy(app, instanceIn)
log.Printf("---> Starting\n")
utils.Debugf("---> Starting")
if err := instance.Start(); err != nil {
Fatalf("start: %v", err)
}
@ -72,7 +72,7 @@ func doCmd(instance *beam.Object, args []string) error {
if len(args) == 0 {
return fmt.Errorf("no command supplied")
}
log.Printf("---> %s\n", args[0])
utils.Debugf("---> %s", args[0])
if args[0] == "ps" {
if len(args) != 1 {
return fmt.Errorf("usage: ps")