slackrus

package
v0.0.0-...-eca9d05 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: GPL-2.0 Imports: 2 Imported by: 0

README

slackrus

Slack hook for Logrus.

Use

package main

import (
	logrus "github.com/Sirupsen/logrus"
	"github.com/johntdyer/slackrus"
	"os"
)

func main() {

	logrus.SetFormatter(&logrus.JSONFormatter{})

	logrus.SetOutput(os.Stderr)

	logrus.SetLevel(logrus.DebugLevel)

	logrus.AddHook(&slackrus.SlackrusHook{
		HookUrl:        "https://hooks.slack.com/services/abc123/defghijklmnopqrstuvwxyz",
		AcceptedLevels: slackrus.LevelThreshold(logrus.DebugLevel),
		Channel:        "#slack-testing",
		IconEmoji:      ":ghost:",
		Username:       "foobot",
	})

	logrus.Warn("warn")
	logrus.Info("info")
	logrus.Debug("debug")
}

Parameters

Required
  • HookUrl
Optional
  • IconEmoji
  • IconUrl
  • Username
  • Channel

Installation

go get github.com/johntdyer/slackrus

Credits

Based on hipchat handler by nuboLAB

Documentation

Overview

Package slackrus provides a Hipchat hook for the logrus loggin package.

Index

Constants

View Source
const (
	VERISON = "0.0.2"
)

Project version

Variables

Supported log levels

Functions

func LevelThreshold

func LevelThreshold(l logrus.Level) []logrus.Level

LevelThreshold - Returns every logging level above and including the given parameter.

Types

type SlackrusHook

type SlackrusHook struct {
	// Messages with a log level not contained in this array
	// will not be dispatched. If nil, all messages will be dispatched.
	AcceptedLevels []logrus.Level
	HookURL        string
	IconURL        string
	Channel        string
	IconEmoji      string
	Username       string
	// contains filtered or unexported fields
}

SlackrusHook is a logrus Hook for dispatching messages to the specified channel on Slack.

func (*SlackrusHook) Fire

func (sh *SlackrusHook) Fire(e *logrus.Entry) error

Fire - Sent event to slack

func (*SlackrusHook) Levels

func (sh *SlackrusHook) Levels() []logrus.Level

Levels sets which levels to sent to slack

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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