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 (
_VERSION = "1.1.0"
_VERSION = "1.1.1"
)
// Version returns current version of the package.

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

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

6
vendor/vendor.json vendored

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

Loading…
Cancel
Save