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 ¶
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 ¶
NewMessage parses a raw syslog packet and returns a Message struct or nil if unparsable.
func (*Message) Facility ¶
Facility returns the curent facility string from a Message (e.g. "local1")
func (*Message) PriorityString ¶
PriorityString returns the curent severity and facility string from a Message (e.g. "local1.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.