diff options
author | Collin Guarino <collin.guarino@gmail.com> | 2016-02-19 00:00:38 -0500 |
---|---|---|
committer | Collin Guarino <collin.guarino@gmail.com> | 2016-02-19 00:00:38 -0500 |
commit | a23f767ed80e115d2e9692b65b5ba9d4ae081d9c (patch) | |
tree | d07c13d71cb6307e45f6b04fb5bd39c57ed8b360 | |
parent | fa741e65856124cec0fba2c5a5c222f1469aaf8d (diff) |
Removed all log output except for errors.
-rw-r--r-- | bridge.go | 17 | ||||
-rw-r--r-- | group.go | 4 | ||||
-rw-r--r-- | light_test.go | 3 | ||||
-rw-r--r-- | scene_test.go | 11 |
4 files changed, 19 insertions, 16 deletions
@@ -72,14 +72,16 @@ func (bridge *Bridge) Put(path string, params interface{}) ([]byte, io.Reader, e data, err := json.Marshal(params) if err != nil { + trace("", err) return []byte{}, nil, err } //fmt.Println("\n\nPARAMS: ", params) - log.Println("\nSending PUT body: ", string(data)) + //log.Println("\nSending PUT body: ", string(data)) request, err := http.NewRequest("PUT", uri, bytes.NewReader(data)) resp, err := client.Do(request) if err != nil { + trace("", err) return []byte{}, nil, err } return HandleResponse(resp) @@ -94,7 +96,7 @@ func (bridge *Bridge) Post(path string, params interface{}) ([]byte, io.Reader, trace("", err) return []byte{}, nil, nil } - log.Println("\nSending POST body: ", string(request)) + //log.Println("\nSending POST body: ", string(request)) // Send the request and handle the response uri := fmt.Sprintf("http://" + bridge.IPAddress + path) @@ -116,6 +118,7 @@ func (bridge *Bridge) Delete(path string) error { } _, _, err = HandleResponse(resp) if err != nil { + trace("", err) return err } return nil @@ -131,22 +134,22 @@ func HandleResponse(resp *http.Response) ([]byte, io.Reader, error) { return []byte{}, nil, err } reader := bytes.NewReader(body) - log.Println("Handled response:\n--------------------\n", string(body) + - "\n--------------------\n") + //log.Println("Handled response:\n------\n", string(body) + "\n------\n") if strings.Contains(string(body), "error") { return []byte{}, nil, errors.New(string(body)) } return body, reader, nil } -// Bridge.Error handles all bridge response status errors -func (bridge *Bridge) Error(resp *http.Response, err error) (bool) { +// Bridge.Error handles all bridge response status errors and +// will return a boolean to notify functions to proceed or not. +func (bridge *Bridge) Error(resp *http.Response, err error) bool { if err != nil { trace("", err) return true } else if resp.StatusCode != 200 { // TODO: handle other status codes - log.Println(fmt.Sprintf("Bridge status error: %d", resp.StatusCode)) + //log.Println(fmt.Sprintf("Bridge status error: %d", resp.StatusCode)) return true } return false @@ -40,14 +40,14 @@ func (bridge *Bridge) GetGroups() ([]Group, error) { return []Group{}, err } - fmt.Println("GROUP GET: ", string(body)) + //fmt.Println("GROUP GET: ", string(body)) groups := map[string]Group{} err = json.Unmarshal(body, &groups) if err != nil { return []Group{}, err } - fmt.Println("GROUPS: ", groups) + //fmt.Println("GROUPS: ", groups) return []Group{}, nil } diff --git a/light_test.go b/light_test.go index 16c4e94..6fa1eb0 100644 --- a/light_test.go +++ b/light_test.go @@ -9,12 +9,11 @@ package hue import ( "testing" - "fmt" + //"fmt" "time" ) func TestSetLightState(t *testing.T) { - fmt.Println("\nTESTING LIGHT STATE:\n\n") bridge, _ := NewBridge("192.168.1.128") bridge.Login("427de8bd6d49f149c8398e4fc08f") nameTest, _ := bridge.GetLightByName("Desk Light") // Also tests GetAllLights diff --git a/scene_test.go b/scene_test.go index 8a74717..945825b 100644 --- a/scene_test.go +++ b/scene_test.go @@ -9,19 +9,20 @@ package hue import ( "testing" - "fmt" + //"fmt" ) func TestGetAllScenes(t *testing.T) { bridge, _ := NewBridge("192.168.1.128") bridge.Login("427de8bd6d49f149c8398e4fc08f") scenes, _ := bridge.GetAllScenes() - for scene := range scenes { - fmt.Println("SCENE: ", scenes[scene]) - } + // for scene := range scenes { + // fmt.Println("SCENE: ", scenes[scene]) + // } individual, _ := bridge.GetScene(scenes[0].ID) - fmt.Println("Individual scene: ", individual) + _ = individual + //fmt.Println("Individual scene: ", individual) } func TestCreateScene(t *testing.T) { |