https://github.com/toorop/logrusovh
OVH logs PAAS Hook for Logrus
https://github.com/toorop/logrusovh
Last synced: 3 months ago
JSON representation
OVH logs PAAS Hook for Logrus
- Host: GitHub
- URL: https://github.com/toorop/logrusovh
- Owner: toorop
- License: mit
- Created: 2016-09-20T10:06:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-07-15T08:38:07.000Z (almost 6 years ago)
- Last Synced: 2025-04-12T21:58:26.199Z (3 months ago)
- Language: Go
- Size: 21.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OVH "paas logs" hook for logrus [](http://godoc.org/github.com/toorop/logrusOVH) [](https://goreportcard.com/report/github.com/toorop/logrusOVH)
Use this hook to send your [Logrus](https://github.com/Sirupsen/logrus) logs to [OVH "Logs Data Platform"](https://www.ovh.com/fr/data-platforms/logs/)
## Installation
```go
go get github.com/toorop/logrusOVH
```## Usage
### GELF
```go
import (
"github.com/Sirupsen/logrus"
"github.com/toorop/logrusOVH"
)
hook, err := NewOvhHook("ENDPOINT","YOUR OVH TOKEN", GELFTCP)
if err != nil {
panic( err)
}
hook.SetCompression(COMPRESSNONE)
log := logrus.New()
log.Out = ioutil.Discard
log.Hooks.Add(hook)
log.WithFields(logrus.Fields{"msgid": "mymsgID", "intField": 1, "T": "TestGelfTCP"}).Error(msg)
```### GELF + GZIP + UDP
```go
import (
"github.com/Sirupsen/logrus"
"github.com/toorop/logrusOVH"
)
hook, err := NewOvhHook("ENDPOINT","YOUR OVH TOKEN", GELFUDP)
if err != nil {
panic( err)
}
hook.SetCompression(COMPRESSGZIP)
log := logrus.New()
log.Out = ioutil.Discard
log.Hooks.Add(hook)
log.WithFields(logrus.Fields{"msgid": "mymsgID", "intField": 1, "T": "GELF + GZIP + UDP"}).Error(msg)
```### Cap'n Proto + TLS
```go
import (
"github.com/Sirupsen/logrus"
"github.com/toorop/logrusOVH"
)
hook, err := NewOvhHook("ENDPOINT","YOUR OVH TOKEN", CAPNPROTOTLS)
if err != nil {
panic( err)
}
hook.SetCompression(COMPRESSNONE)
log := logrus.New()
log.Out = ioutil.Discard
log.Hooks.Add(hook)
log.WithFields(logrus.Fields{"msgid": "mymsgID", "intField": 1, "T": "TestGelfTCP"}).Error(msg)
```
### async
Just use:```go
hook, err := NewAsyncOvhHook("ENDPOINT","YOUR OVH TOKEN", CAPNPROTOTLS)
```## Available serialisations, transport
* GELFTCP: Gelf serialisation & TCP transport
* GELFUDP: Gelf serialisation & UDP transport
* GELFTLS: Gelf serialisation & TCP/TLS transport
* CAPNPROTOTCP: Cap'n proto serialisation & TCP transport
* CAPNPROTOTLS: Cap'n proto serialisation & TCP/TLS transport## Available compression
* COMPRESSNONE: no compression (default)
* COMPRESSGZIP: GZIP compression for GELF
* COMPRESSZLIB ZLIB compression for GELF
* COMPRESSPACKNPPACKED: cap'n proto packed (not working yet)