Version: v2.1.1+incompatible Latest Latest

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

Go to latest
Published: May 22, 2017 License: BSD-3-Clause Imports: 5 Imported by: 0



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 (

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:



This section is empty.


This section is empty.


This section is empty.


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.

Source Files

Jump to

Keyboard shortcuts

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