papertrailgo

package module
v0.0.0-...-ab261ef Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 26 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Papertrail-go

Papertrail-go is a Go (golang) library built using Go modules for shipping logs to Papertrail using syslog over udp or tcp or tls.

Warning: This is a Go library project. It will NOT produce a consumable executable.

Papertrail

In order to ship logs to Papertrail, you will need a Papertrail account. If you don't have one already, you can sign up for one here. After you are logged in, you will need to create a Log Destination from under the Settings menu. When a log destination is created, you will be given a host:port combo.

For any help with Papertrail, please check out their help page here.

Usage

To get the package:

go get github.com/solarwinds/papertrail-go

For a detailed usage example, please check out: https://github.com/solarwinds/cabbage/blob/master/logshipper/papertrail.go

For development, you should be able to clone this repository to any convenient location on your machine.

To run all the static checks:

make lint

To run tests:

make tests

Questions/Comments?

Please open an issue, we'd love to hear from you. As a SolarWinds Project, it is supported in a best-effort fashion.

Documentation

Overview

Package papertrailgo is a Go library package which contains code for shipping logs to papertrail

Index

Constants

View Source
const (
	// UDP represents UDP protocol
	UDP syslogProto = "udp"

	// TCP represents TCP protocol
	TCP syslogProto = "tcp"

	// TLS represents TLS protocol
	TLS syslogProto = "tcp+tls"
)

Variables

View Source
var File_payload_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Logger

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

Logger is a concrete type of LoggerInterface which collects and ships logs to Papertrail

func NewPapertrailLogger

func NewPapertrailLogger(ctx context.Context, paperTrailProtocol, paperTrailHost string, paperTrailPort int, tag, dbLocation string, retention time.Duration,
	workerCount int, maxDiskUsage float64) (*Logger, error)

NewPapertrailLogger creates a papertrail log shipper and also returns an instance of Logger

func NewPapertrailLoggerWithShipper

func NewPapertrailLoggerWithShipper(ctx context.Context, dbLocation string, retention time.Duration,
	workerCount int, maxDiskUsage float64, sLogWriter papertrailShipper) (*Logger, error)

NewPapertrailLoggerWithShipper does some ground work and returns an instance of Logger

func (*Logger) Close

func (p *Logger) Close() error

Close - closes the Logger instance

func (*Logger) Log

func (p *Logger) Log(payload *Payload) error

Log method receives log messages

type LoggerInterface

type LoggerInterface interface {
	Log(*Payload) error
	Close() error
}

LoggerInterface is the interface for all Papertrail logger types

type Payload

type Payload struct {
	Hostname string               `protobuf:"bytes,1,opt,name=hostname,proto3" json:"hostname,omitempty"`
	Tag      string               `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"`
	LogTime  *timestamp.Timestamp `protobuf:"bytes,3,opt,name=log_time,json=logTime,proto3" json:"log_time,omitempty"`
	Log      string               `protobuf:"bytes,4,opt,name=log,proto3" json:"log,omitempty"`
	// contains filtered or unexported fields
}

func (*Payload) Descriptor deprecated

func (*Payload) Descriptor() ([]byte, []int)

Deprecated: Use Payload.ProtoReflect.Descriptor instead.

func (*Payload) GetHostname

func (x *Payload) GetHostname() string

func (*Payload) GetLog

func (x *Payload) GetLog() string

func (*Payload) GetLogTime

func (x *Payload) GetLogTime() *timestamp.Timestamp

func (*Payload) GetTag

func (x *Payload) GetTag() string

func (*Payload) ProtoMessage

func (*Payload) ProtoMessage()

func (*Payload) ProtoReflect

func (x *Payload) ProtoReflect() protoreflect.Message

func (*Payload) Reset

func (x *Payload) Reset()

func (*Payload) String

func (x *Payload) String() string

type SrslogShipper

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

SrslogShipper represents srslog shipper

func NewPapertailShipper

func NewPapertailShipper(paperTrailProtocol, paperTrailHost string, paperTrailPort int, tag string) (*SrslogShipper, error)

NewPapertailShipper creates an instance of the papertrail shipper with the given protocol, host, port

func (*SrslogShipper) Close

func (s *SrslogShipper) Close() error

Close will close the syslog writer

func (*SrslogShipper) Dial

func (s *SrslogShipper) Dial() (err error)

Dial attempts to dial a syslog connection

func (*SrslogShipper) Formatter

func (s *SrslogShipper) Formatter(p syslog.Priority, hostname, tag, content string) string

Formatter is actually a dummy placeholder

func (*SrslogShipper) Write

func (s *SrslogShipper) Write(packet *SyslogPacket) (err error)

Write writes packets on the wire

type SyslogPacket

type SyslogPacket struct {
	Severity syslog.Priority
	Hostname string
	Tag      string
	Time     time.Time
	Message  string
}

A SyslogPacket represents an RFC5425 syslog message

Jump to

Keyboard shortcuts

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