Home

Awesome

vkrus

Build Status PkgGoDev codecov VK chat release license

Logrus hook for VK using VKSDK.

Usage

This library is packaged using Go modules. You can get it via:

# go mod init mymodulename
go get github.com/SevereCloud/vkrus/v2@latest

The hook must be configured with:

package main

import (
	vkrus "github.com/SevereCloud/vkrus/v2"
	log "github.com/sirupsen/logrus"
)

func init() {
	peerID := 117253521   // USE strconv.Atoi(os.Getenv("PEER_ID"))
	groupToken := "token" // USE os.Getenv("TOKEN")
	hook := vkrus.NewHook(peerID, groupToken)
	hook.UseLevels = log.AllLevels

	log.AddHook(hook)
}

func main() {
	log.Trace("Something very low level.")
	log.Debug("Useful debugging information.")
	log.Info("Something noteworthy happened!")
	log.Warn("You should probably take a look at this.")
	log.Error("Something failed but I'm not quitting.")
}

DefaultLevels to be fired when logging on

var DefaultLevels = []logrus.Level{
	logrus.ErrorLevel,
	logrus.FatalLevel,
	logrus.PanicLevel,
}

Optional params:

License

FOSSA Status