syslogger

package
v2.0.0-alpha2+incompat... Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2015 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package syslogger uses the event package to listen for any event that implements the Syslogger interface. The listener calls the Syslog method on the event, which should return a severity and a message.

The tag for messages sent to syslog will be the program name (os.Args[0]), and the facility number will be 1 (user-level).

For example, to declare that your event type MyEvent should be sent to syslog, implement the Syslog() method to define how the message should be formatted and which severity it should have (see package "log/syslog" for details).

import (
	"fmt"
	"log/syslog"
	"syslogger"
)

type MyEvent struct {
	field1, field2 string
}

func (ev *MyEvent) Syslog() (syslog.Priority, string) {
	return syslog.LOG_INFO, fmt.Sprintf("event: %v, %v", ev.field1, ev.field2)
}
var _ syslogger.Syslogger = (*MyEvent)(nil) // compile-time interface check

The compile-time interface check is optional but recommended because usually there is no other static conversion in these cases. See:

http://golang.org/doc/effective_go.html#blank_implements

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Syslogger

type Syslogger interface {
	// Syslog should return a severity (not a facility) and a message.
	Syslog() (syslog.Priority, string)
}

Syslogger is the interface that events should implement if they want to be dispatched to this package.

Jump to

Keyboard shortcuts

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