Skip to content

SevereCloud/vkrus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  • A peer ID (
    • For user: 'User ID', e.g. 12345
    • For chat: '2000000000' + 'chat_id', e.g. 2000000001 (chat_id for community)
  • Access Token with messages rights (found in your community settings)
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:

  • AppName
  • UseLevels
  • Extra
  • Asynchronous
  • Disabled
  • DontParseLinks
  • DisableMentions

License

FOSSA Status