ovhlogs

package module
v0.0.0-...-40d33da Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: MIT Imports: 12 Imported by: 0

README

go-ovh-logs

Golang package for sending logs to the OVH logs PAAS

GoDoc

It's completely API compatible with the standard library logger.

It implements GELF format (TCP or UDP, compressed or not).

Example:

package main

import (
	ovhlogs "github.com/toorop/go-ovh-logs"
)

func main() {
	OVHLogger := ovhlogs.New("STREAM_TOKEN", ovhlogs.GelfUDP, ovhlogs.CompressNone, false)
	OVHLogger.Print("Hello World !")
}

See Examples folder for more... examples ;)

Support this project & open-source

If this project is useful for you, please consider making a donation.

Bitcoin

Address: 1JvMRNRxiTiN9H7LyZTq4yzR7ez86M7ND6

Bitcoin QR code

Ethereum

Address: 0xA84684B45969efbD54fd25A1e2eD8C7790A0C497

ETH QR code

Documentation

Index

Constants

View Source
const (
	// CompressNone No compression
	CompressNone = 1 + iota
	// CompressGzip GZIP compression for GELF
	CompressGzip
	// CompressZlib ZLIB compression for GELF
	CompressZlib
	// CompressDeflate DEFLATE for GELF
	CompressDeflate
)
View Source
const (
	// UDPChunkMaxSizeFrag max chunk size (fragmented)
	UDPChunkMaxSizeFrag = 8192
	// UDPChunkMaxSize chunk max size
	UDPChunkMaxSize = 1420
	// UDPChunkMaxDataSize chunk data max size
	UDPChunkMaxDataSize = 1348 // UDP_CHUNK_MAX_SIZE - ( 2 + 8 + 1 + 1)
)

Constants usefull for UDP

View Source
const Endpoint = "gra1.logs.ovh.com"

Endpoint is OVH log Endpoint

Variables

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

Functions

This section is empty.

Types

type CompressAlgo

type CompressAlgo uint8

CompressAlgo is the compression algorithm used

func (CompressAlgo) String

func (c CompressAlgo) String() string

type Entry

type Entry struct {
	Version      string  `json:"version"`
	Host         string  `json:"host"`
	ShortMessage string  `json:"short_message"`
	FullMessage  string  `json:"full_message"`
	Timestamp    float64 `json:"time_stamp"`
	Level        uint8   `json:"level"`
	Line         uint    `json:"line"`
	OvhToken     string  `json:"_X-OVH-TOKEN"`
}

Entry represent a log entry to push to OVH logs PAAS

type OvhLogs

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

OvhLogs represents a OVH logs PAAS wrapper

func New

func New(endpoint, ovhToken string, proto Protocol, compression CompressAlgo, isAsync bool) *OvhLogs

New return a new OvhLogs

func (*OvhLogs) Error

func (o *OvhLogs) Error(v ...interface{}) error

func (*OvhLogs) Fatal

func (o *OvhLogs) Fatal(v ...interface{})

Fatal for log.Fatal interface Warning: error are dropped

func (*OvhLogs) Fatalf

func (o *OvhLogs) Fatalf(format string, v ...interface{})

Fatalf for log.Fatalf interface Warning: error are dropped

func (*OvhLogs) Fatalln

func (o *OvhLogs) Fatalln(v ...interface{})

Fatalln for log.Fatalln interface Warning: error are dropped

func (*OvhLogs) Info

func (o *OvhLogs) Info(v ...interface{}) error

Info send log message @info level

func (*OvhLogs) Panic

func (o *OvhLogs) Panic(v ...interface{})

Panic for log.Panic

func (*OvhLogs) Panicf

func (o *OvhLogs) Panicf(format string, v ...interface{})

Panicf for log.Panicf

func (*OvhLogs) Panicln

func (o *OvhLogs) Panicln(v ...interface{})

Panicln for log.Panicln

func (*OvhLogs) Print

func (o *OvhLogs) Print(v ...interface{}) error

Print for log.Print interface

func (*OvhLogs) Printf

func (o *OvhLogs) Printf(format string, v ...interface{}) error

Printf for log.Printf interface

func (*OvhLogs) Println

func (o *OvhLogs) Println(v ...interface{}) error

Println for log.Println interface

func (*OvhLogs) Send

func (o *OvhLogs) Send(e Entry) (err error)

Send a Entry to ovh logs

type Protocol

type Protocol uint8

Protocol used to push logs to OVH PAAS

const (
	// GelfUDP for Gelf + UDP
	GelfUDP Protocol = 1 + iota
	// GelfTCP for Gelf + TCP
	GelfTCP
	// GelfTLS for Gelf + TLS
	GelfTLS
)

func (Protocol) String

func (p Protocol) String() string

reverse map

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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