Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/h1z3y3/logrus-udp2es-hook
https://github.com/h1z3y3/logrus-udp2es-hook
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/h1z3y3/logrus-udp2es-hook
- Owner: h1z3y3
- License: mit
- Created: 2019-04-01T06:58:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-08T10:48:49.000Z (about 5 years ago)
- Last Synced: 2024-06-20T16:49:44.415Z (7 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Logrus-udp2es-hook
用于写入udp地址走后续自动入ES流程
## Usage
```go
import (
"github.com/sirupsen/logrus"
"github.com/h1z3y3/logrus-udp2es-hook"
)func main() {
// logrus 必须设置为json输出
logrus.SetFormatter(&logrus.JSONFormatter{})// 初始化hook
hook, err := logrus_udp2es.NewUdp2EsHook(&logrus_udp2es.Hook{
Host: "127.0.0.1", // your udp server host
Port: 12345, // your udp server port
ESIndex: "test-index", // your es index
})// 只记录指定Level的日志
hook.SetLevels([]logrus.Level{logrus.ErrorLevel, logrus.WarnLevel})if err == nil {
logrus.AddHook(hook)
} else {
logrus.Error("add hook error:", err)
}logrus.Warning("Here is your message")
}
```## ChangeLog