logging

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2016 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 added in v0.5.0

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

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

func NewDockerLogParser added in v0.5.0

func NewDockerLogParser(logger *log.Logger) *DockerLogParser

NewDockerLogParser creates a new DockerLogParser

func (*DockerLogParser) Parse added in v0.5.0

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 *log.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 added in v0.5.0

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 *log.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 {
	IsolationConfig *cstructs.IsolationConfig
	Addr            string
}

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

type SyslogMessage added in v0.3.2

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

SyslogMessage represents a log line received

type SyslogServer added in v0.3.2

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

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

func NewSyslogServer added in v0.5.0

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

NewSyslogServer creates a new syslog server

func (*SyslogServer) Shutdown added in v0.3.2

func (s *SyslogServer) Shutdown()

Shutdown shutsdown the syslog server

func (*SyslogServer) Start added in v0.5.0

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