|
|
|
@ -3,6 +3,7 @@ package amclient
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"log"
|
|
|
|
|
"net/http"
|
|
|
|
|
"net/url"
|
|
|
|
|
"time"
|
|
|
|
@ -36,6 +37,10 @@ func (client Client) post(values url.Values) error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (cl Client) Ping() error {
|
|
|
|
|
if cl.reportURL == "" {
|
|
|
|
|
log.Printf("AM ping")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return cl.post(url.Values{
|
|
|
|
|
"action": []string{"ping"},
|
|
|
|
|
})
|
|
|
|
@ -43,6 +48,10 @@ func (cl Client) Ping() error {
|
|
|
|
|
|
|
|
|
|
func (cl Client) Log(text string, args ...interface{}) error {
|
|
|
|
|
text = fmt.Sprintf(text, args...)
|
|
|
|
|
if cl.reportURL == "" {
|
|
|
|
|
log.Printf("AM log: %s", text)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return cl.post(url.Values{
|
|
|
|
|
"action": []string{"log"},
|
|
|
|
|
"text": []string{text},
|
|
|
|
@ -51,6 +60,10 @@ func (cl Client) Log(text string, args ...interface{}) error {
|
|
|
|
|
|
|
|
|
|
func (cl Client) Alert(text string, args ...interface{}) error {
|
|
|
|
|
text = fmt.Sprintf(text, args...)
|
|
|
|
|
if cl.reportURL == "" {
|
|
|
|
|
log.Printf("AM alert: %s", text)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return cl.post(url.Values{
|
|
|
|
|
"action": []string{"alert"},
|
|
|
|
|
"text": []string{text},
|
|
|
|
|