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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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