capture

package
v0.0.0-...-7dafc29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Stdout outputPanic = iota + 1
	Slack
	Email
)

Variables

View Source
var CapturePanicGo = func() {
	if captureConfig == nil {
		log.Panicln("capture config is not set")
	}
	if err := recover(); err != nil {
		switch captureConfig.OutputPanic {
		case Slack:
			notifySlack(err)
		case Stdout:
			printToStdOut(err)
		default:
			log.Println(captureConfig.OutputPanic, " has not supported yet")
		}
	}
}

Functions

func CapturePanic

func CapturePanic(h http.Handler) http.Handler

func InitCapture

func InitCapture(c *Config)

func InitSlack

func InitSlack(c *SlackClient)

func Send

func Send(message SlackMessage) error

Types

type Attachment

type Attachment struct {
	Color         string      `json:"color,omitempty"`
	Fallback      string      `json:"fallback,omitempty"`
	CallbackID    string      `json:"callback_id,omitempty"`
	ID            int         `json:"id,omitempty"`
	AuthorID      string      `json:"author_id,omitempty"`
	AuthorName    string      `json:"author_name,omitempty"`
	AuthorSubname string      `json:"author_subname,omitempty"`
	AuthorLink    string      `json:"author_link,omitempty"`
	AuthorIcon    string      `json:"author_icon,omitempty"`
	Title         string      `json:"title,omitempty"`
	TitleLink     string      `json:"title_link,omitempty"`
	Pretext       string      `json:"pretext,omitempty"`
	Text          string      `json:"text,omitempty"`
	ImageURL      string      `json:"image_url,omitempty"`
	ThumbURL      string      `json:"thumb_url,omitempty"`
	MarkdownIn    []string    `json:"mrkdwn_in,omitempty"`
	Ts            json.Number `json:"ts,omitempty"`
}

type Config

type Config struct {
	OutputPanic outputPanic
	ShowTrace   bool
	SlackClient SlackClient
}

type SlackClient

type SlackClient struct {
	WebHookUrl  string
	UserName    string
	Channel     string
	MentionUser []string //UserID slack
	MentionHere bool
	Environment string
	TimeOut     time.Duration
}

type SlackMessage

type SlackMessage struct {
	Username    string       `json:"username,omitempty"`
	IconEmoji   string       `json:"icon_emoji,omitempty"`
	Channel     string       `json:"channel,omitempty"`
	Text        string       `json:"text,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL