syslogd

package
v0.0.0-...-9c23c6b Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package syslogd provides a library to write syslog servers.

Example

sys := syslogd.NewServer(syslog.Options{SockAddr: config.C.SockAddr, UnixPath: config.C.UnixPath})
go func() {
	for {
		msg := sys.Next()
		if msg == nil {
			// no more messages, server exiting
		}
}()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NumActiveNodes

func NumActiveNodes(secs int) int

NumActiveNodes returns the number of nodes which have sent messages during the last X secs.

Types

type Message

type Message struct {
	Received time.Time
	Priority syslog.Priority
	Hostname string
	Tag      string
	Pid      int
	Raw      []byte
}

Message defines all parsable fields of a syslog message. Not all fields might be available in each message.

func NewMessage

func NewMessage(pkt []byte, size int) (*Message, error)

NewMessage parses a raw syslog packet and returns a Message struct or nil if unparsable.

func (*Message) Facility

func (m *Message) Facility() string

Facility returns the curent facility string from a Message (e.g. "local1")

func (*Message) PriorityString

func (m *Message) PriorityString() string

PriorityString returns the curent severity and facility string from a Message (e.g. "local1.notice")

func (*Message) Severity

func (m *Message) Severity() string

Severity returns the curent severity string from a Message (e.g. "notice")

type Options

type Options struct {
	// SockAddr contains the listening port for UDP and TCP listeners, default is ":514"
	SockAddr string

	// UnixPath contains the unix socket path for unix syslogging. If you are running
	// this a the primary server on a unix system set this to "/dev/log" (which is default)
	// otherwise you're free to choose a path depending on what your application uses.
	UnixPath string

	// BufferSize contains the maximum number of messages queued before we block.
	// Defaults to 128k
	BufferSize int

	// LogDir defines the path where to store logfiles. Leave empty to not write logfiles.
	LogDir string
}

Options contain all configuration required for operating a syslog server. If one or more options are blank, unix syslogd defaults are used.

type Server

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

Server contains internal data for syslog server processes.

func NewServer

func NewServer(opts Options) *Server

NewServer creates and initializes a new syslog server process.

func (*Server) Close

func (s *Server) Close()

Close closes the syslog server.

func (*Server) Next

func (s *Server) Next() *Message

Next retrieves the next message from the syslog queue.

Jump to

Keyboard shortcuts

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