diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e92f57 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tags diff --git a/fcm.go b/fcm.go index 55e0dd4..93837b4 100644 --- a/fcm.go +++ b/fcm.go @@ -21,7 +21,7 @@ import ( "net/http" "net/textproto" - "git.bit5.ru/backend/colog" + "github.com/go-logr/logr" "git.bit5.ru/backend/errors" "golang.org/x/oauth2" ) @@ -80,10 +80,10 @@ type Client struct { cfg ClientConfig ts oauth2.TokenSource hc *http.Client - logger *colog.CoLog + logger logr.Logger } -func NewClient(cfg ClientConfig, ts oauth2.TokenSource, hc *http.Client, logger *colog.CoLog) *Client { +func NewClient(cfg ClientConfig, ts oauth2.TokenSource, hc *http.Client, logger logr.Logger) *Client { return &Client{ cfg: cfg, ts: ts, @@ -120,7 +120,7 @@ func (c *Client) doSendRequest(req SendRequest) (SendResponse, error) { if err != nil { return SendResponse{}, errors.WithStack(err) } - c.logger.Logf("sending message: %s", data) + c.logger.Info("sending", "message", data) request, err := http.NewRequest(http.MethodPost, c.cfg.SendEndpoint, bytes.NewReader(data)) if err != nil { @@ -280,7 +280,7 @@ func (c *Client) makeMultiSendResponse(response *http.Response, totalCount int) responses = append(responses, resp) if resp.HasError() { - c.logger.Logf("error: %+v", *resp.Error) + c.logger.Info("fail", "error", fmt.Sprintf("%+v", *resp.Error)) fails++ } } diff --git a/go.mod b/go.mod index 7f33dad..413bcea 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.bit5.ru/backend/fcm go 1.13 require ( - git.bit5.ru/backend/colog v1.0.0 git.bit5.ru/backend/errors v1.0.0 golang.org/x/oauth2 v0.1.0 + github.com/go-logr/logr v1.2.3 ) diff --git a/go.sum b/go.sum index ea2ce4b..a470ea4 100644 --- a/go.sum +++ b/go.sum @@ -93,6 +93,8 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=