瀏覽代碼

remove repeating logging to reduce unnecessary verbosity

Tiger Wang 2 年之前
父節點
當前提交
7bd5c6a2b4
共有 1 個文件被更改,包括 3 次插入6 次删除
  1. 3 6
      common/notify.go

+ 3 - 6
common/notify.go

@@ -25,7 +25,6 @@ type notifyService struct {
 }
 
 func (n *notifyService) SendNotify(path string, message map[string]interface{}) error {
-
 	url := strings.TrimSuffix(n.address, "/") + APICasaOSNotify + "/" + path
 	body, err := json.Marshal(message)
 	if err != nil {
@@ -40,15 +39,13 @@ func (n *notifyService) SendNotify(path string, message map[string]interface{})
 		return errors.New("failed to send notify (status code: " + fmt.Sprint(response.StatusCode) + ")")
 	}
 	return nil
-
 }
 
 // disk: "sys_disk":{"size":56866869248,"avail":5855485952,"health":true,"used":48099700736}
 // usb:   "sys_usb":[{"name": "sdc","size": 7747397632,"model": "DataTraveler_2.0","avail": 7714418688,"children": null}]
 func (n *notifyService) SendSystemStatusNotify(message map[string]interface{}) error {
-
 	url := strings.TrimSuffix(n.address, "/") + APICasaOSNotify + "/system_status"
-	fmt.Println(url)
+
 	body, err := json.Marshal(message)
 	if err != nil {
 		return err
@@ -62,8 +59,8 @@ func (n *notifyService) SendSystemStatusNotify(message map[string]interface{}) e
 		return errors.New("failed to send notify (status code: " + fmt.Sprint(response.StatusCode) + ")")
 	}
 	return nil
-
 }
+
 func NewNotifyService(runtimePath string) (NotifyService, error) {
 	casaosAddressFile := filepath.Join(runtimePath, CasaOSURLFilename)
 
@@ -79,7 +76,7 @@ func NewNotifyService(runtimePath string) (NotifyService, error) {
 		return nil, err
 	}
 
-	if response.StatusCode != 200 {
+	if response.StatusCode != http.StatusOK {
 		return nil, errors.New("failed to ping casaos service")
 	}