gelf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2017 License: MIT, MIT Imports: 11 Imported by: 0

README

Gelf

Golang client for Graylog Extended Log Format (GELF)

Documentation

Overview

Graylog2 GELF client

Index

Constants

View Source
const (
	UDP_NETWORK     = "udp"
	MESSAGE_ID_SIZE = 8
)
View Source
const (
	GELF_VERSION = "1.2"
)
View Source
const TCP_NETWORK = "tcp"

Variables

View Source
var (
	CHUNCK_MAGIC_DATA = []byte{0x1e, 0x0f}
	HEADER_SIZE       = len(CHUNCK_MAGIC_DATA) + MESSAGE_ID_SIZE + sequenceInfoSize
)
View Source
var GZIP_MAGIC_PREFIX = []byte{0x1F, 0x8B}
View Source
var MESSAGE_SEPARATOR = []byte{0}
View Source
var (
	UNSUPPORTED_COMPRESSION_TYPE = fmt.Errorf("Unsupported compression type")
)

Functions

This section is empty.

Types

type CompressionType

type CompressionType string
const (
	COMPRESSION_NONE CompressionType = "none"
	COMPRESSION_GZIP CompressionType = "gzip"
)

type GelfClient

type GelfClient struct {
	GelfProtocolClient
	CompressionType
	CompressionLevel int
}

func NewGelfClient

func NewGelfClient(gelfProtocolClient GelfProtocolClient, compressionType CompressionType) *GelfClient

func (*GelfClient) SendMessage

func (gelfClient *GelfClient) SendMessage(message interface{}) error

type GelfProtocolClient

type GelfProtocolClient interface {
	SendMessageData(messageData MessageData) error
}

type Message

type Message struct {
	Version      string  `json:"version"`
	Host         string  `json:"host"`
	ShortMessage string  `json:"short_message"`
	Timestamp    float64 `json:"timestamp"`
	Level        l.Level `json:"level"`
	FullMessage  string  `json:"full_message,omitempty"`
	Facility     string  `json:"facility,omitempty"`
	Line         uint    `json:"line,omitempty"`
	File         string  `json:"file,omitempty"`
}

func NewMessage

func NewMessage(source string, level l.Level, shortMessage string) *Message

type MessageData

type MessageData []byte

type MessageId

type MessageId []byte

type TcpClient

type TcpClient struct {
	ServerAddr *net.TCPAddr
	// contains filtered or unexported fields
}

func MustTcpClient

func MustTcpClient(host string, port uint16) *TcpClient

func NewTcpClient

func NewTcpClient(host string, port uint16) (*TcpClient, error)

func (*TcpClient) SendMessageData

func (tcpClient *TcpClient) SendMessageData(message MessageData) error

type TcpConnMng

type TcpConnMng struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func DialTcpMng

func DialTcpMng(net string, laddr, raddr *net.TCPAddr) (*TcpConnMng, error)

func (*TcpConnMng) Close

func (tcpConnMng *TcpConnMng) Close() error

func (*TcpConnMng) LocalAddr

func (tcpConnMng *TcpConnMng) LocalAddr() net.Addr

func (*TcpConnMng) Read

func (tcpConnMng *TcpConnMng) Read(b []byte) (n int, err error)

func (*TcpConnMng) RemoteAddr

func (tcpConnMng *TcpConnMng) RemoteAddr() net.Addr

func (*TcpConnMng) SetDeadline

func (tcpConnMng *TcpConnMng) SetDeadline(t time.Time) error

func (*TcpConnMng) SetReadDeadline

func (tcpConnMng *TcpConnMng) SetReadDeadline(t time.Time) error

func (*TcpConnMng) SetWriteDeadline

func (tcpConnMng *TcpConnMng) SetWriteDeadline(t time.Time) error

func (*TcpConnMng) Write

func (tcpConnMng *TcpConnMng) Write(b []byte) (n int, err error)

type UdpClient

type UdpClient struct {
	ServerAddr *net.UDPAddr
	ChunkSize  uint
}

func MustUdpClient

func MustUdpClient(host string, port uint16, chunkSize uint) *UdpClient

func NewUdpClient

func NewUdpClient(host string, port uint16, chunkSize uint) (*UdpClient, error)

func (*UdpClient) SendMessageData

func (udpClient *UdpClient) SendMessageData(messageData MessageData) error

Jump to

Keyboard shortcuts

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