syslog
packagestandard libraryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package syslog provides a simple interface to the system logservice. It can send messages to the syslog daemon using UNIXdomain sockets, UDP or TCP.
Only one call to Dial is necessary. On write failures,the syslog client will attempt to reconnect to the serverand 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
Index¶
- func NewLogger(p Priority, logFlag int) (*log.Logger, error)
- type Priority
- type Writer
- func (w *Writer) Alert(m string) error
- func (w *Writer) Close() error
- func (w *Writer) Crit(m string) error
- func (w *Writer) Debug(m string) error
- func (w *Writer) Emerg(m string) error
- func (w *Writer) Err(m string) error
- func (w *Writer) Info(m string) error
- func (w *Writer) Notice(m string) error
- func (w *Writer) Warning(m string) error
- func (w *Writer) Write(b []byte) (int, error)
- Bugs
Examples¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcNewLogger¶
NewLogger creates alog.Logger whose output is written to thesystem log service with the specified priority, a combination ofthe syslog facility and severity. The logFlag argument is the flagset passed through tolog.New to create the Logger.
Types¶
typePriority¶
type Priorityint
The Priority is a combination of the syslog facility andseverity. For example,LOG_ALERT |LOG_FTP sends an alert severitymessage from the FTP facility. The default severity isLOG_EMERG;the default facility isLOG_KERN.
const (// From /usr/include/sys/syslog.h.// These are the same up to LOG_FTP on Linux, BSD, and OS X.LOG_KERNPriority =iota << 3LOG_USERLOG_MAILLOG_DAEMONLOG_AUTHLOG_SYSLOGLOG_LPRLOG_NEWSLOG_UUCPLOG_CRONLOG_AUTHPRIVLOG_FTPLOG_LOCAL0LOG_LOCAL1LOG_LOCAL2LOG_LOCAL3LOG_LOCAL4LOG_LOCAL5LOG_LOCAL6LOG_LOCAL7)
typeWriter¶
type Writer struct {// contains filtered or unexported fields}
A Writer is a connection to a syslog server.
funcDial¶
Dial establishes a connection to a log daemon by connecting toaddress raddr on the specified network. Each write to the returnedwriter sends a log message with the facility and severity(from priority) and tag. If tag is empty, theos.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 valuesof network and raddr.
Example¶
package mainimport ("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.")}
funcNew¶
New establishes a new connection to the system log daemon. Eachwrite to the returned writer sends a log message with the givenpriority (a combination of the syslog facility and severity) andprefix tag. If tag is empty, theos.Args[0] is used.
func (*Writer)Alert¶
Alert logs a message with severityLOG_ALERT, ignoring the severitypassed to New.
func (*Writer)Debug¶
Debug logs a message with severityLOG_DEBUG, ignoring the severitypassed to New.
func (*Writer)Emerg¶
Emerg logs a message with severityLOG_EMERG, ignoring the severitypassed to New.
func (*Writer)Notice¶
Notice logs a message with severityLOG_NOTICE, ignoring theseverity passed to New.
func (*Writer)Warning¶
Warning logs a message with severityLOG_WARNING, ignoring theseverity passed to New.
Notes¶
Bugs¶
This package is not implemented on Windows. As thesyslog package is frozen, Windows users are encouraged touse a package outside of the standard library. For background,seehttps://golang.org/issue/1108.
This package is not implemented on Plan 9.