remove repeating logging to reduce unnecessary verbosity

This commit is contained in:
Tiger Wang 2022-10-27 11:59:35 -04:00
parent 230f1585a3
commit 7bd5c6a2b4

View file

@ -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")
}