Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/severecloud/vkrus
VK Hook for Logrus
https://github.com/severecloud/vkrus
golang logrus logrus-hook vk vk-api
Last synced: 2 months ago
JSON representation
VK Hook for Logrus
- Host: GitHub
- URL: https://github.com/severecloud/vkrus
- Owner: SevereCloud
- License: mit
- Created: 2020-02-29T11:22:45.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-03T12:47:26.000Z (6 months ago)
- Last Synced: 2024-09-26T05:03:55.256Z (3 months ago)
- Topics: golang, logrus, logrus-hook, vk, vk-api
- Language: Go
- Homepage:
- Size: 90.8 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vkrus
[![Build Status](https://travis-ci.com/SevereCloud/vkrus.svg?branch=master)](https://travis-ci.com/SevereCloud/vkrus)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/SevereCloud/vkrus/v2)](https://pkg.go.dev/github.com/SevereCloud/vkrus/v2)
[![codecov](https://codecov.io/gh/SevereCloud/vkrus/branch/master/graph/badge.svg)](https://codecov.io/gh/SevereCloud/vkrus)
[![VK chat](https://img.shields.io/badge/VK%20chat-%234a76a8.svg?logo=VK&logoColor=white)](https://vk.me/join/AJQ1d6Or8Q00Y_CSOESfbqGt)
[![release](https://img.shields.io/github/v/tag/SevereCloud/vkrus?label=release)](https://github.com/SevereCloud/vkrus/releases)
[![license](https://img.shields.io/github/license/SevereCloud/vkrus.svg?maxAge=2592000)](https://github.com/SevereCloud/vkrus/blob/master/LICENSE)[Logrus](https://github.com/sirupsen/logrus) hook for [VK](https://vk.com) using [VKSDK](https://github.com/SevereCloud/vksdk).
### Usage
This library is packaged using [Go modules](https://github.com/golang/go/wiki/Modules). You can get it via:
```sh
# 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](https://vk.com/dev/access_token) with **messages** rights (found in your community settings)```go
package mainimport (
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.AllLevelslog.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
```go
var DefaultLevels = []logrus.Level{
logrus.ErrorLevel,
logrus.FatalLevel,
logrus.PanicLevel,
}
```Optional params:
- AppName
- UseLevels
- Extra
- Asynchronous
- Disabled
- DontParseLinks
- DisableMentions### License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSevereCloud%2Fvkrus.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FSevereCloud%2Fvkrus?ref=badge_large)