Browse Source

vendor: update gopkg.in/clog.v1

pull/5126/head
Unknwon 7 years ago
parent
commit
0f737f2999
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 2
      vendor/gopkg.in/clog.v1/clog.go
  2. 45
      vendor/gopkg.in/clog.v1/slack.go
  3. 6
      vendor/vendor.json

2
vendor/gopkg.in/clog.v1/clog.go generated vendored

@ -24,7 +24,7 @@ import (
) )
const ( const (
_VERSION = "1.1.0" _VERSION = "1.1.1"
) )
// Version returns current version of the package. // Version returns current version of the package.

45
vendor/gopkg.in/clog.v1/slack.go generated vendored

@ -16,22 +16,24 @@ package clog
import ( import (
"bytes" "bytes"
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
) )
type slackAttachment struct {
Text string `json:"text"`
Color string `json:"color"`
}
type slackPayload struct {
Attachments []slackAttachment `json:"attachments"`
}
const ( const (
SLACK = "slack" SLACK = "slack"
_SLACK_ATTACHMENT = `{
"attachments": [
{
"text": "%s",
"color": "%s"
}
]
}`
) )
var slackColors = []string{ var slackColors = []string{
@ -92,13 +94,30 @@ func (s *slack) ExchangeChans(errorChan chan<- error) chan *Message {
return s.msgChan return s.msgChan
} }
func buildSlackAttachment(msg *Message) string { func buildSlackPayload(msg *Message) (string, error) {
return fmt.Sprintf(_SLACK_ATTACHMENT, msg.Body, slackColors[msg.Level]) payload := slackPayload{
Attachments: []slackAttachment{
{
Text: msg.Body,
Color: slackColors[msg.Level],
},
},
}
p, err := json.Marshal(&payload)
if err != nil {
return "", err
}
return string(p), nil
} }
func (s *slack) write(msg *Message) { func (s *slack) write(msg *Message) {
attachment := buildSlackAttachment(msg) payload, err := buildSlackPayload(msg)
resp, err := http.Post(s.url, "application/json", bytes.NewReader([]byte(attachment))) if err != nil {
s.errorChan <- fmt.Errorf("slack.buildSlackPayload: %v", err)
return
}
resp, err := http.Post(s.url, "application/json", bytes.NewReader([]byte(payload)))
if err != nil { if err != nil {
s.errorChan <- fmt.Errorf("slack: %v", err) s.errorChan <- fmt.Errorf("slack: %v", err)
} }

6
vendor/vendor.json vendored

@ -567,10 +567,10 @@
"revisionTime": "2015-09-24T05:17:56Z" "revisionTime": "2015-09-24T05:17:56Z"
}, },
{ {
"checksumSHA1": "ZJBrUSDBKgkXID1MVRkXSTlmOh4=", "checksumSHA1": "AbDfvggt92trYSRhGRqXW5uQ4aU=",
"path": "gopkg.in/clog.v1", "path": "gopkg.in/clog.v1",
"revision": "ff5a366d133e02b3d411dbe3854ebd912a434c7f", "revision": "8492a6faa632c31ba82f562b53b4a6e5eacf2732",
"revisionTime": "2017-03-23T22:33:02Z" "revisionTime": "2017-05-26T21:48:39Z"
}, },
{ {
"checksumSHA1": "LIu3jihd3edOyIsJJK3V6vx2UZg=", "checksumSHA1": "LIu3jihd3edOyIsJJK3V6vx2UZg=",

Loading…
Cancel
Save