Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codehakase/slack-logrus
:memo::memo: An Intuitive Logrus Hook for Slack
https://github.com/codehakase/slack-logrus
go golang hooks logging logrus logs slack
Last synced: 22 days ago
JSON representation
:memo::memo: An Intuitive Logrus Hook for Slack
- Host: GitHub
- URL: https://github.com/codehakase/slack-logrus
- Owner: codehakase
- Created: 2018-05-08T07:27:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-22T17:33:05.000Z (over 4 years ago)
- Last Synced: 2024-10-02T09:13:14.349Z (about 1 month ago)
- Topics: go, golang, hooks, logging, logrus, logs, slack
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# slack-logrus [![Build Status](https://travis-ci.org/codehakase/slack-logrus.svg?branch=master)](https://travis-ci.org/polds/logrus-papertrail-hook) [![godoc reference](https://godoc.org/github.com/codehakase/slack-logrus?status.png)](https://godoc.org/github.com/codehakase/slack-logrus)
:memo::memo: An Intuitive Logrus Hook for Slack
## Sample
![SlackLogrus ScreenShot](http://res.cloudinary.com/hakase-labs/image/upload/v1525777621/slack-logrus_hexonr.png)
## Installation
Using `go get`
```shell
$ go get -u github.com/codehakase/slack-logrus
```## Usage
Log Directly to A Slack Channel```go
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
```go
fields := map[string]interface{}{
"hostname": "hakaselabs",
"source": os.Getenv("APISource"),
"tag": "test-tag",
}
logrus.AddHook(&slacklogrus.Hook{
...
Options: fields,
})
```