logrusOVH

package module
v0.0.0-...-67d7edb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2019 License: MIT Imports: 17 Imported by: 1

README

OVH "paas logs" hook for logrus GoDoc Go Report Card

Use this hook to send your Logrus logs to OVH "Logs Data Platform"

Installation

go get github.com/toorop/logrusOVH

Usage

GELF
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
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
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:

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)

Documentation

Index

Constants

View Source
const (
	// COMPRESSNONE No compression
	COMPRESSNONE = 1 + iota
	// COMPRESSGZIP GZIP compression for GELF
	COMPRESSGZIP
	// COMPRESSZLIB ZLIB compression for GELF
	COMPRESSZLIB
	// COMPRESSPACKNPPACKED compression for cap'n proto
	COMPRESSPACKNPPACKED
	// COMPRESSDEFLATE DEFLATE compression for GELF
	COMPRESSDEFLATE
)
View Source
const (

	// UDP_CHUNK_MAX_SIZE_FRAG max chunk size (fragmented)
	UDP_CHUNK_MAX_SIZE_FRAG = 8192
	//UDP_CHUNK_MAX_SIZE        = 8164 // 8192 - (IP header) - (UDP header)
	//UDP_CHUNK_MAX_DATA_SIZE   = 8144 // UDP_CHUNK_MAX_SIZE - ( 2 + 8 + 1 + 1)
	//UDP_CHUNK_MAX_SIZE      = 1420
	// UDP_CHUNK_MAX_SIZE chunk max size
	UDP_CHUNK_MAX_SIZE = 1420
	// UDP_CHUNK_MAX_DATA_SIZE chunk data max size
	UDP_CHUNK_MAX_DATA_SIZE = 1348 // UDP_CHUNK_MAX_SIZE - ( 2 + 8 + 1 + 1)
)

Variables

View Source
var Endpoint string

Endpoint OVH logs endpoint

View Source
var (
	// GELF_CHUNK_MAGIC_BYTES "magic bytes" for GELF chunk headers
	GELF_CHUNK_MAGIC_BYTES = []byte{0x1e, 0x0f}
)

Functions

This section is empty.

Types

type CompressAlgo

type CompressAlgo uint8

CompressAlgo the compression algorithm used

func (CompressAlgo) String

func (c CompressAlgo) String() string

type Entry

type Entry struct {
	// contains filtered or unexported fields
}

Entry represent the base entry

type OvhHook

type OvhHook struct {
	// contains filtered or unexported fields
}

OvhHook represents an OVH PAAS Log

func NewAsyncOvhHook

func NewAsyncOvhHook(endpoint, ovhToken string, proto Protocol) (*OvhHook, error)

NewAsyncOvhHook returns a async hook

func NewOvhHook

func NewOvhHook(endpoint, ovhToken string, proto Protocol) (*OvhHook, error)

NewOvhHook returns a sync Hook

func (*OvhHook) Fire

func (hook *OvhHook) Fire(logrusEntry *logrus.Entry) error

Fire is called when a log event is fired.

func (*OvhHook) Levels

func (hook *OvhHook) Levels() []logrus.Level

Levels returns the available logging levels (interface impl)

func (*OvhHook) SetCompression

func (hook *OvhHook) SetCompression(algo CompressAlgo) error

SetCompression set compression algorithm

type Protocol

type Protocol uint8

Protocol define available transfert proto

const (
	// GELFUDP for Gelf + UDP
	GELFUDP Protocol = 1 + iota
	// GELFTCP for Gelf + TCP
	GELFTCP
	// GELFTLS for Gelf + TLS
	GELFTLS
	// CAPNPROTOUDP for Cap'n proto + UDP
	CAPNPROTOUDP
	// CAPNPROTOTCP for Cap'n proto + TCP
	CAPNPROTOTCP
	// CAPNPROTOTLS for Cap'n proto + TLS
	CAPNPROTOTLS
)

func (Protocol) String

func (p Protocol) String() string

reverse map

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL