https://github.com/vlcty/logrus-integram-horn-hook
https://github.com/vlcty/logrus-integram-horn-hook
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vlcty/logrus-integram-horn-hook
- Owner: vlcty
- License: mit
- Created: 2019-07-13T18:04:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-13T19:49:58.000Z (almost 6 years ago)
- Last Synced: 2025-03-17T13:05:51.840Z (2 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# logrus-integram-horn-hook
Logrus hook to send log messages to [integram](https://integram.org/) using their webhook service.
All you need to do is start a chat with [https://t.me/bullhorn_bot](@bullhorn_bot). The bot will greet you with a message containing your webhook ID. For example:```
https://integram.org/webhook/supersecret123
```In this example the webhook ID is `supersecret123`. Save it because you need it later!
## Example
Simple example to send a telegram message if an error is logged:
```go
package mainimport (
"github.com/sirupsen/logrus"
hornhook "github.com/vlcty/logrus-integram-horn-hook"
)func main() {
hook := hornhook.New("supersecret123s") // Set your webhook ID here
// hook.Appname = "Test"
hook.AddLevel(logrus.ErrorLevel)logrus.AddHook(hook)
logrus.Error("test123")
}
```In the example you will receive a Telegram message like this:
```
[ERROR] test123
```If you specify the app name the message changes slightly:
```
(Test) [ERROR] test123
```## Levels
By default the hook doesn't register any log levels. You have to add them yourself before calling `logrus.AddHook`!