takuoki / slack-alert

A Golang package for alerts using Slack.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

slack-alert (slacka)

GoDoc MIT License

A Golang package for alerts using Slack.

Installation

go get github.com/takuoki/slack-alert/slacka

Usage

Create New Client

client := slacka.New("username", "service name", "icon url")
client.SetURL("URL_KEY1", "https://hooks.slack.com/services/xxx/xxx/xxxxx")
client.SetURL("URL_KEY2", "https://hooks.slack.com/services/yyy/yyy/yyyyy")
client.SetErrorURL("https://hooks.slack.com/services/zzz/zzz/zzzzz")

Send Message

err := client.Send("URL_KEY1", "This is message!")

You can change username and icon url with options.

err := client.Send("URL_KEY1", "This is message!",
  slacka.WebhookUsername("new username"),
  slacka.WebhookIconURL("new icon url"))

Send Error Message

Every method has a method of format type like Debugf.

// Debug
err := client.Debug("This is message!")
// Info
err := client.Info("This is message!")
// Warn
err := client.Warn("This is message!")
// Error
err := client.Error("This is message!")
// Fatal
err := client.Fatal("This is message!")

About

A Golang package for alerts using Slack.

License:MIT License


Languages

Language:Go 100.0%