watcher

package module
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: MIT Imports: 1 Imported by: 0

README

Watcher

A simple and efficient package to handle staging and production errors.

go get github.com/Alvarios/watcher

Prerequisite

You need a Slack application that supports incoming webhooks.

Configuration

Create a SlackConfig in your go code.

package myPackage

import "github.com/Alvarios/watcher"

var Watcher watcher.SlackConfig

func main() {
    Watcher := watcher.SlackConfig{
        WebHook: "https://hooks.slack.com/services/XXXXX/XXXXX/XXXXX",
        Application: "Your application name",
    }
}

Methods

Error

Send a basic error message to Slack.

package myPackage

func MyFunction() {
	_, err := Watcher.Error("some error message")
}
Fatal

Same as Error method, but kills the running server and doesn't return any status.

package myPackage

func MyFunction() {
	Watcher.Fatal("some fatal message")
}
GinAbort

A special message formatter for Gin, that also interrupts the request.

package myPackage

import "github.com/gin-gonic/gin"

func MyMiddleware(c *gin.Context) {
	Watcher.GinAbort(c, "some error message")
}

2020 Kushuh - MIT license

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SlackConfig

type SlackConfig = setup.SlackConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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