telegrus

package module
v0.0.0-...-6f0977c Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: MIT Imports: 7 Imported by: 0

README

Telegram Hooks for Logrus

Install

$ go get github.com/Hu13er/telegrus

Usage

package main

import (
    "github.com/sirupsen/logrus"
    "github.com/Hu13er/telegrus"
)

func main() {
    log := logrus.New()
    
    var (
        botToken = ""      // Your Bot token
        chatID = int64(0) // Your chatID
    )

    logrus.AddHook(
        telegrus.NewHooker(botToken, chatID).
            MentionOn(logrus.WarnLevel,
                "Hu13er", "foobar").
            MentionOn(logrus.ErrorLevel,
                "Huberrr").
            SetLevel(logrus.InfoLevel),
    )

    logrus.Debugln("This is a DEBUG")
    logrus.Infoln("This is an INFO")
    logrus.Warnln("This is a WARN")
    logrus.Errorln("This is an ERROR")
    fmt.Scanln()
}

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TextFormatter = &logrus.TextFormatter{DisableColors: true}
	JSONFormatter = &logrus.JSONFormatter{}
)

Functions

func NewHooker

func NewHooker(botToken string, chatID int64) *hooker

Types

This section is empty.

Jump to

Keyboard shortcuts

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