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: 12 days 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 (8 months ago)
- Last Synced: 2025-01-01T10:12:42.417Z (about 2 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
[](https://travis-ci.com/SevereCloud/vkrus)
[](https://pkg.go.dev/github.com/SevereCloud/vkrus/v2)
[](https://codecov.io/gh/SevereCloud/vkrus)
[](https://vk.me/join/AJQ1d6Or8Q00Y_CSOESfbqGt)
[](https://github.com/SevereCloud/vkrus/releases)
[](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
[](https://app.fossa.io/projects/git%2Bgithub.com%2FSevereCloud%2Fvkrus?ref=badge_large)