Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toorop/logrusovh
OVH logs PAAS Hook for Logrus
https://github.com/toorop/logrusovh
Last synced: about 6 hours 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 (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-15T08:38:07.000Z (over 5 years ago)
- Last Synced: 2024-06-21T14:39:24.764Z (5 months ago)
- Language: Go
- Size: 21.5 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OVH "paas logs" hook for logrus [![GoDoc](http://godoc.org/github.com/toorop/logrusOVH?status.svg)](http://godoc.org/github.com/toorop/logrusOVH) [![Go Report Card](https://goreportcard.com/badge/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)