syslog

package
v2.721.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package syslog provides a simple interface to the system log service. It can send messages to the syslog daemon using UDP or TCP.

Only one call to Dial is necessary. On write failures, the syslog client will attempt to reconnect to the server and write again.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Priority

type Priority int

The Priority is a combination of the syslog facility and severity. For example, LOG_ALERT | LOG_FTP sends an alert severity message from the FTP facility. The default severity is LOG_EMERG; the default facility is LOG_KERN.

const (
	LOG_EMERG   Priority = iota //nolint:revive
	LOG_ALERT                   //nolint:revive
	LOG_CRIT                    //nolint:revive
	LOG_ERR                     //nolint:revive
	LOG_WARNING                 //nolint:revive
	LOG_NOTICE                  //nolint:revive
	LOG_INFO                    //nolint:revive
	LOG_DEBUG                   //nolint:revive
)
const (
	LOG_KERN     Priority = iota << 3 //nolint:revive
	LOG_USER                          //nolint:revive
	LOG_MAIL                          //nolint:revive
	LOG_DAEMON                        //nolint:revive
	LOG_AUTH                          //nolint:revive
	LOG_SYSLOG                        //nolint:revive
	LOG_LPR                           //nolint:revive
	LOG_NEWS                          //nolint:revive
	LOG_UUCP                          //nolint:revive
	LOG_CRON                          //nolint:revive
	LOG_AUTHPRIV                      //nolint:revive
	LOG_FTP                           //nolint:revive

	LOG_LOCAL0 //nolint:revive
	LOG_LOCAL1 //nolint:revive
	LOG_LOCAL2 //nolint:revive
	LOG_LOCAL3 //nolint:revive
	LOG_LOCAL4 //nolint:revive
	LOG_LOCAL5 //nolint:revive
	LOG_LOCAL6 //nolint:revive
	LOG_LOCAL7 //nolint:revive
)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

A Writer is a connection to a syslog server.

func Dial

func Dial(network, raddr string, priority Priority, tag string) (*Writer, error)

Dial establishes a connection to a log daemon by connecting to address raddr on the specified network. Each write to the returned writer sends a log message with the given facility, severity and tag.

func DialHostname

func DialHostname(network, raddr string, priority Priority, tag, hostname string) (*Writer, error)

func (*Writer) Alert

func (w *Writer) Alert(m string) error

Alert logs a message with severity LOG_ALERT, ignoring the severity passed to New.

func (*Writer) Close

func (w *Writer) Close() error

Close closes a connection to the syslog daemon.

func (*Writer) Crit

func (w *Writer) Crit(m string) error

Crit logs a message with severity LOG_CRIT, ignoring the severity passed to New.

func (*Writer) Debug

func (w *Writer) Debug(m string) error

Debug logs a message with severity LOG_DEBUG, ignoring the severity passed to New.

func (*Writer) Emerg

func (w *Writer) Emerg(m string) error

Emerg logs a message with severity LOG_EMERG, ignoring the severity passed to New.

func (*Writer) Err

func (w *Writer) Err(m string) error

Err logs a message with severity LOG_ERR, ignoring the severity passed to New.

func (*Writer) Info

func (w *Writer) Info(m string) error

Info logs a message with severity LOG_INFO, ignoring the severity passed to New.

func (*Writer) Notice

func (w *Writer) Notice(m string) error

Notice logs a message with severity LOG_NOTICE, ignoring the severity passed to New.

func (*Writer) Warning

func (w *Writer) Warning(m string) error

Warning logs a message with severity LOG_WARNING, ignoring the severity passed to New.

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

Write sends a log message to the syslog daemon.

Jump to

Keyboard shortcuts

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