go-vitess.v1: gopkg.in/src-d/go-vitess.v1/event/syslogger Index | Files

package syslogger

import "gopkg.in/src-d/go-vitess.v1/event/syslogger"

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

Package Files

syslogger.go

type Syslogger Uses

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.

Package syslogger imports 5 packages (graph) and is imported by 6 packages. Updated 2019-06-13. Refresh now. Tools for package owners.