This hook emits log messages (and corresponding fields) to the Telegram API for logrus. Currently this hook will only emit messages for the following levels:
ERROR
FATAL
PANIC
Install the package with:
go get github.com/rossmcdonald/telegram_hook
See the tests for working examples. Also:
import (
"time"
log "github.com/Sirupsen/logrus"
"github.com/rossmcdonald/telegram_hook"
)
func main() {
hook, err := telegram_hook.NewTelegramHook(
"MyCoolApp",
"MYTELEGRAMTOKEN",
"@mycoolusername",
telegram_hook.WithAsync(true),
telegram_hook.WithTimeout(30 * time.Second),
)
if err != nil {
log.Fatalf("Encountered error when creating Telegram hook: %s", err)
}
log.AddHook(hook)
// Receive messages on failures
log.Errorf("Uh oh...")
...
}
MIT