Skip to content

HakaseLabs/slack-logrus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

slack-logrus :walrus: Build Status godoc reference

📝📝 An Intuitive Logrus Hook for Slack

Sample

SlackLogrus ScreenShot

Installation

Using go get

$ go get -u github.com/codehakase/slack-logrus

Usage

Log Directly to A Slack Channel

package main
import (
  "github.com/codehakase/slack-logrus"
  "github.com/sirupsen/logrus"
)

func main() {

  logrus.SetOutput(os.Stderr)
  logrus.AddHook(&sl.Hook{
    SlackHookURL: "https://hooks.slack.com/services/xxxxxx/xxxxxx/xxxxxxx",
    Username:     "slack-logrus",
    IconEmoji:    ":mega:",
    WithLevels:   logrus.AllLevels,
    Channel:      "#dev-channel",
  })
  logrus.Info("Hey I'm test running my package!!!")
}

Send Extra Loggin Data

To send custom fields to aid understand logging use add an Options field

fields := map[string]interface{}{
  "hostname": "hakaselabs",
  "source":   os.Getenv("APISource"),
  "tag":      "test-tag",
}
logrus.AddHook(&slacklogrus.Hook{
  ...
  Options: fields,
})

About

📝📝 An Intuitive Logrus Hook for Slack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%