gosyslogd: github.com/tomarus/gosyslogd/syslogd Index | Files

package syslogd

import "github.com/tomarus/gosyslogd/syslogd"

Package syslogd provides a library to write syslog servers.


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


Package Files

archive.go msg.go server.go

func NumActiveNodes Uses

func NumActiveNodes(secs int) int

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

type Message Uses

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 Uses

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 Uses

func (m *Message) Facility() string

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

func (*Message) PriorityString Uses

func (m *Message) PriorityString() string

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

func (*Message) Severity Uses

func (m *Message) Severity() string

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

type Options Uses

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 Uses

type Server struct {
    // contains filtered or unexported fields

Server contains internal data for syslog server processes.

func NewServer Uses

func NewServer(opts Options) *Server

NewServer creates and initializes a new syslog server process.

func (*Server) Close Uses

func (s *Server) Close()

Close closes the syslog server.

func (*Server) Next Uses

func (s *Server) Next() *Message

Next retrieves the next message from the syslog queue.

Package syslogd imports 14 packages (graph) and is imported by 1 packages. Updated 2017-02-26. Refresh now. Tools for package owners.