package syslog

Import Path
	log/syslog (on go.dev)

Dependency Relation
	imports 8 packages, and imported by 0 packages

Involved Source Files Package syslog provides a simple interface to the system log service. It can send messages to the syslog daemon using UNIX domain sockets, 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. The syslog package is frozen and is not accepting new features. Some external packages provide more functionality. See: https://godoc.org/?q=syslog syslog.go syslog_unix.go
Code Examples package main import ( "fmt" "log" "log/syslog" ) func main() { sysLog, err := syslog.Dial("tcp", "localhost:1234", syslog.LOG_WARNING|syslog.LOG_DAEMON, "demotag") if err != nil { log.Fatal(err) } fmt.Fprintf(sysLog, "This is a daemon warning with demotag.") sysLog.Emerg("And this is a daemon emergency with demotag.") }
Package-Level Type Names (total 2)
/* sort by: | */
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]. func Dial(network, raddr string, priority Priority, tag string) (*Writer, error) func New(priority Priority, tag string) (*Writer, error) func NewLogger(p Priority, logFlag int) (*log.Logger, error) const LOG_ALERT const LOG_AUTH const LOG_AUTHPRIV const LOG_CRIT const LOG_CRON const LOG_DAEMON const LOG_DEBUG const LOG_EMERG const LOG_ERR const LOG_FTP const LOG_INFO const LOG_KERN const LOG_LOCAL0 const LOG_LOCAL1 const LOG_LOCAL2 const LOG_LOCAL3 const LOG_LOCAL4 const LOG_LOCAL5 const LOG_LOCAL6 const LOG_LOCAL7 const LOG_LPR const LOG_MAIL const LOG_NEWS const LOG_NOTICE const LOG_SYSLOG const LOG_USER const LOG_UUCP const LOG_WARNING
A Writer is a connection to a syslog server. Alert logs a message with severity [LOG_ALERT], ignoring the severity passed to New. Close closes a connection to the syslog daemon. Crit logs a message with severity [LOG_CRIT], ignoring the severity passed to New. Debug logs a message with severity [LOG_DEBUG], ignoring the severity passed to New. Emerg logs a message with severity [LOG_EMERG], ignoring the severity passed to New. Err logs a message with severity [LOG_ERR], ignoring the severity passed to New. Info logs a message with severity [LOG_INFO], ignoring the severity passed to New. Notice logs a message with severity [LOG_NOTICE], ignoring the severity passed to New. Warning logs a message with severity [LOG_WARNING], ignoring the severity passed to New. Write sends a log message to the syslog daemon. *Writer : internal/bisect.Writer *Writer : io.Closer *Writer : io.WriteCloser *Writer : io.Writer func Dial(network, raddr string, priority Priority, tag string) (*Writer, error) func New(priority Priority, tag string) (*Writer, error)
Package-Level Functions (total 3)
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 facility and severity (from priority) and tag. If tag is empty, the [os.Args][0] is used. If network is empty, Dial will connect to the local syslog server. Otherwise, see the documentation for net.Dial for valid values of network and raddr.
New establishes a new connection to the system log daemon. Each write to the returned writer sends a log message with the given priority (a combination of the syslog facility and severity) and prefix tag. If tag is empty, the [os.Args][0] is used.
NewLogger creates a [log.Logger] whose output is written to the system log service with the specified priority, a combination of the syslog facility and severity. The logFlag argument is the flag set passed through to [log.New] to create the Logger.
Package-Level Constants (total 28)
const LOG_ALERT Priority = 1
const LOG_AUTH Priority = 32
const LOG_CRIT Priority = 2
const LOG_CRON Priority = 72
const LOG_DAEMON Priority = 24
const LOG_DEBUG Priority = 7
From /usr/include/sys/syslog.h. These are the same on Linux, BSD, and OS X.
const LOG_ERR Priority = 3
const LOG_FTP Priority = 88
const LOG_INFO Priority = 6
From /usr/include/sys/syslog.h. These are the same up to LOG_FTP on Linux, BSD, and OS X.
const LOG_LOCAL0 Priority = 128
const LOG_LOCAL1 Priority = 136
const LOG_LOCAL2 Priority = 144
const LOG_LOCAL3 Priority = 152
const LOG_LOCAL4 Priority = 160
const LOG_LOCAL5 Priority = 168
const LOG_LOCAL6 Priority = 176
const LOG_LOCAL7 Priority = 184
const LOG_LPR Priority = 48
const LOG_MAIL Priority = 16
const LOG_NEWS Priority = 56
const LOG_NOTICE Priority = 5
const LOG_SYSLOG Priority = 40
const LOG_USER Priority = 8
const LOG_UUCP Priority = 64