Imports #
"errors"
"fmt"
"log"
"net"
"os"
"strings"
"sync"
"time"
"errors"
"net"
"errors"
"fmt"
"log"
"net"
"os"
"strings"
"sync"
"time"
"errors"
"net"
const LOG_ALERT
const LOG_AUTH
const LOG_AUTHPRIV
const LOG_CRIT
const LOG_CRON
const LOG_DAEMON
const LOG_DEBUG
From /usr/include/sys/syslog.h. These are the same on Linux, BSD, and OS X.
const LOG_EMERG Priority = iota
const LOG_ERR
const LOG_FTP
const LOG_INFO
From /usr/include/sys/syslog.h. These are the same up to LOG_FTP on Linux, BSD, and OS X.
const LOG_KERN Priority = *ast.BinaryExpr
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
const _
const _
const _
const _
const facilityMask = 0xf8
const severityMask = 0x07
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].
type Priority int
This interface and the separate syslog_unix.go file exist for Solaris support as implemented by gccgo. On Solaris you cannot simply open a TCP connection to the syslog daemon. The gccgo sources have a syslog_solaris.go file that implements unixSyslog to return a type that satisfies this interface and simply calls the C library syslog function.
type serverConn interface {
writeString(p Priority, hostname string, tag string, s string, nl string) error
close() error
}
A Writer is a connection to a syslog server.
type Writer struct {
priority Priority
tag string
hostname string
network string
raddr string
mu sync.Mutex
conn serverConn
}
type netConn struct {
local bool
conn net.Conn
}
Alert logs a message with severity [LOG_ALERT], ignoring the severity passed to New.
func (w *Writer) Alert(m string) error
Close closes a connection to the syslog daemon.
func (w *Writer) Close() error
Crit logs a message with severity [LOG_CRIT], ignoring the severity passed to New.
func (w *Writer) Crit(m string) error
Debug logs a message with severity [LOG_DEBUG], ignoring the severity passed to New.
func (w *Writer) Debug(m string) 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 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.
func Dial(network string, raddr string, priority Priority, tag string) (*Writer, error)
Emerg logs a message with severity [LOG_EMERG], ignoring the severity passed to New.
func (w *Writer) Emerg(m string) error
Err logs a message with severity [LOG_ERR], ignoring the severity passed to New.
func (w *Writer) Err(m string) error
Info logs a message with severity [LOG_INFO], ignoring the severity passed to New.
func (w *Writer) Info(m string) error
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.
func New(priority Priority, tag string) (*Writer, error)
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.
func NewLogger(p Priority, logFlag int) (*log.Logger, error)
Notice logs a message with severity [LOG_NOTICE], ignoring the severity passed to New.
func (w *Writer) Notice(m string) error
Warning logs a message with severity [LOG_WARNING], ignoring the severity passed to New.
func (w *Writer) Warning(m string) error
Write sends a log message to the syslog daemon.
func (w *Writer) Write(b []byte) (int, error)
func (n *netConn) close() error
connect makes a connection to the syslog server. It must be called with w.mu held.
func (w *Writer) connect() (err error)
func unixSyslog() (conn serverConn, err error)
write generates and writes a syslog formatted string. The
format is as follows:
func (w *Writer) write(p Priority, msg string) (int, error)
func (w *Writer) writeAndRetry(p Priority, s string) (int, error)
func (n *netConn) writeString(p Priority, hostname string, tag string, msg string, nl string) error
Generated with Arrow