logging

package
v0.9.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PRI_PART_START = '<'
	PRI_PART_END   = '>'
)

Priority header and ending characters

Variables

View Source
var (
	ErrPriorityNoStart  = fmt.Errorf("No start char found for priority")
	ErrPriorityEmpty    = fmt.Errorf("Priority field empty")
	ErrPriorityNoEnd    = fmt.Errorf("No end char found for priority")
	ErrPriorityTooShort = fmt.Errorf("Priority field too short")
	ErrPriorityTooLong  = fmt.Errorf("Priority field too long")
	ErrPriorityNonDigit = fmt.Errorf("Non digit found in priority")
)

Errors related to parsing priority

Functions

This section is empty.

Types

type DockerLogParser

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

DockerLogParser parses a line of log message that the docker daemon ships

func NewDockerLogParser

func NewDockerLogParser(logger hclog.Logger) *DockerLogParser

NewDockerLogParser creates a new DockerLogParser

func (*DockerLogParser) Parse

func (d *DockerLogParser) Parse(line []byte) *SyslogMessage

Parse parses a syslog log line

type FileRotator

type FileRotator struct {
	MaxFiles int   // MaxFiles is the maximum number of rotated files allowed in a path
	FileSize int64 // FileSize is the size a rotated file is allowed to grow
	// contains filtered or unexported fields
}

FileRotator writes bytes to a rotated set of files

func NewFileRotator

func NewFileRotator(path string, baseFile string, maxFiles int,
	fileSize int64, logger hclog.Logger) (*FileRotator, error)

NewFileRotator returns a new file rotator

func (*FileRotator) Close

func (f *FileRotator) Close()

func (*FileRotator) Write

func (f *FileRotator) Write(p []byte) (n int, err error)

Write writes a byte array to a file and rotates the file if it's size becomes equal to the maximum size the user has defined.

type LogCollector

type LogCollector interface {
	LaunchCollector(ctx *LogCollectorContext) (*SyslogCollectorState, error)
	Exit() error
	UpdateLogConfig(logConfig *structs.LogConfig) error
}

LogCollector is an interface which allows a driver to launch a log server and update log configuration

type LogCollectorContext

type LogCollectorContext struct {
	// TaskName is the name of the Task
	TaskName string

	// AllocDir is the handle to do operations on the alloc dir of
	// the task
	AllocDir *allocdir.AllocDir

	// LogConfig provides configuration related to log rotation
	LogConfig *structs.LogConfig

	// PortUpperBound is the upper bound of the ports that we can use to start
	// the syslog server
	PortUpperBound uint

	// PortLowerBound is the lower bound of the ports that we can use to start
	// the syslog server
	PortLowerBound uint
}

LogCollectorContext holds context to configure the syslog server

type Priority

type Priority struct {
	Pri      int
	Facility syslog.Priority
	Severity syslog.Priority
}

Priority holds all the priority bits in a syslog log line

type SyslogCollector

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

SyslogCollector is a LogCollector which starts a syslog server and does rotation to incoming stream

func NewSyslogCollector

func NewSyslogCollector(logger hclog.Logger) *SyslogCollector

NewSyslogCollector returns an implementation of the SyslogCollector

func (*SyslogCollector) Exit

func (s *SyslogCollector) Exit() error

Exit kills the syslog server

func (*SyslogCollector) LaunchCollector

func (s *SyslogCollector) LaunchCollector(ctx *LogCollectorContext) (*SyslogCollectorState, error)

LaunchCollector launches a new syslog server and starts writing log lines to files and rotates them

func (*SyslogCollector) UpdateLogConfig

func (s *SyslogCollector) UpdateLogConfig(logConfig *structs.LogConfig) error

UpdateLogConfig updates the log configuration

type SyslogCollectorState

type SyslogCollectorState struct {
	Addr string
}

SyslogCollectorState holds the address and isolation information of a launched syslog server

type SyslogMessage

type SyslogMessage struct {
	Message  []byte
	Severity syslog.Priority
}

SyslogMessage represents a log line received

type SyslogServer

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

SyslogServer is a server which listens to syslog messages and parses them

func NewSyslogServer

func NewSyslogServer(l net.Listener, messages chan *SyslogMessage, logger hclog.Logger) *SyslogServer

NewSyslogServer creates a new syslog server

func (*SyslogServer) Shutdown

func (s *SyslogServer) Shutdown()

Shutdown the syslog server

func (*SyslogServer) Start

func (s *SyslogServer) Start()

Start starts accepting syslog connections

Jump to

Keyboard shortcuts

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