diff --git a/connection.go b/connection.go index e7df318d..aa1ebe1c 100644 --- a/connection.go +++ b/connection.go @@ -1,7 +1,7 @@ package gobot import ( - "fmt" + "log" ) type connection struct { @@ -34,22 +34,22 @@ func NewConnection(adaptor AdaptorInterface, r *Robot) *connection { } func (c *connection) Connect() bool { - fmt.Println("Connecting to " + c.Name + " on port " + c.Port + "...") + log.Println("Connecting to " + c.Name + " on port " + c.Port + "...") return c.Adaptor.Connect() } func (c *connection) Disconnect() bool { - fmt.Println("Disconnecting " + c.Name + "...") + log.Println("Disconnecting " + c.Name + "...") return c.Adaptor.Disconnect() } func (c *connection) Finalize() bool { - fmt.Println("Finalizing " + c.Name + "...") + log.Println("Finalizing " + c.Name + "...") return c.Adaptor.Finalize() } func (c *connection) Reconnect() bool { - fmt.Println("Reconnecting to " + c.Name + " on port " + c.Port + "...") + log.Println("Reconnecting to " + c.Name + " on port " + c.Port + "...") return c.Adaptor.Reconnect() } diff --git a/device.go b/device.go index 806041e5..e955e915 100644 --- a/device.go +++ b/device.go @@ -1,7 +1,7 @@ package gobot import ( - "fmt" + "log" ) type device struct { @@ -27,7 +27,7 @@ func NewDevice(driver DriverInterface, r *Robot) *device { } func (d *device) Start() bool { - fmt.Println("Device " + d.Name + " started") + log.Println("Device " + d.Name + " started") return d.Driver.Start() } diff --git a/gobot_suite_test.go b/gobot_suite_test.go index 66d00240..33736246 100644 --- a/gobot_suite_test.go +++ b/gobot_suite_test.go @@ -3,11 +3,18 @@ package gobot import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - + "log" "testing" ) +type null struct{} + +func (null) Write(p []byte) (int, error) { + return len(p), nil +} + func TestGobot(t *testing.T) { + log.SetOutput(new(null)) RegisterFailHandler(Fail) RunSpecs(t, "Gobot Suite") } diff --git a/robot.go b/robot.go index 8cb4d05b..c7d53a41 100644 --- a/robot.go +++ b/robot.go @@ -2,6 +2,7 @@ package gobot import ( "fmt" + "log" "math/rand" "time" ) @@ -55,27 +56,27 @@ func (r *Robot) initCommands() { func (r *Robot) initConnections() { r.connections = make([]*connection, len(r.Connections)) - fmt.Println("Initializing connections...") + log.Println("Initializing connections...") for i := range r.Connections { - fmt.Sprintln("Initializing connection %v...", FieldByNamePtr(r.Connections[i], "Name")) + log.Println("Initializing connection ", FieldByNamePtr(r.Connections[i], "Name"), "...") r.connections[i] = NewConnection(r.Connections[i], r) } } func (r *Robot) initDevices() { r.devices = make([]*device, len(r.Devices)) - fmt.Println("Initializing devices...") + log.Println("Initializing devices...") for i := range r.Devices { - fmt.Sprintln("Initializing device %v...", FieldByNamePtr(r.Devices[i], "Name")) + log.Println("Initializing device ", FieldByNamePtr(r.Devices[i], "Name"), "...") r.devices[i] = NewDevice(r.Devices[i], r) } } func (r *Robot) startConnections() bool { - fmt.Println("Starting connections...") + log.Println("Starting connections...") success := true for i := range r.connections { - fmt.Println("Starting connection " + r.connections[i].Name + "...") + log.Println("Starting connection " + r.connections[i].Name + "...") if r.connections[i].Connect() == false { success = false break @@ -85,10 +86,10 @@ func (r *Robot) startConnections() bool { } func (r *Robot) startDevices() bool { - fmt.Println("Starting devices...") + log.Println("Starting devices...") success := true for i := range r.devices { - fmt.Println("Starting device " + r.devices[i].Name + "...") + log.Println("Starting device " + r.devices[i].Name + "...") if r.devices[i].Start() == false { success = false break