Imports #
"errors"
"fmt"
"log"
"net"
"os"
"strings"
"sync"
"time"
"errors"
"net"
"errors"
"fmt"
"log"
"net"
"os"
"strings"
"sync"
"time"
"errors"
"net"
const LOG_ALERTconst LOG_AUTHconst LOG_AUTHPRIVconst LOG_CRITconst LOG_CRONconst LOG_DAEMONconst LOG_DEBUGFrom /usr/include/sys/syslog.h. These are the same on Linux, BSD, and OS X.
const LOG_EMERG Priority = iotaconst LOG_ERRconst LOG_FTPconst LOG_INFOFrom /usr/include/sys/syslog.h. These are the same up to LOG_FTP on Linux, BSD, and OS X.
const LOG_KERN Priority = *ast.BinaryExprconst LOG_LOCAL0const LOG_LOCAL1const LOG_LOCAL2const LOG_LOCAL3const LOG_LOCAL4const LOG_LOCAL5const LOG_LOCAL6const LOG_LOCAL7const LOG_LPRconst LOG_MAILconst LOG_NEWSconst LOG_NOTICEconst LOG_SYSLOGconst LOG_USERconst LOG_UUCPconst LOG_WARNINGconst _const _const _const _const facilityMask = 0xf8const severityMask = 0x07The 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 intThis 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) errorClose closes a connection to the syslog daemon.
func (w *Writer) Close() errorCrit logs a message with severity [LOG_CRIT], ignoring the severity passed to New.
func (w *Writer) Crit(m string) errorDebug logs a message with severity [LOG_DEBUG], ignoring the severity passed to New.
func (w *Writer) Debug(m string) errorDial 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) errorErr logs a message with severity [LOG_ERR], ignoring the severity passed to New.
func (w *Writer) Err(m string) errorInfo logs a message with severity [LOG_INFO], ignoring the severity passed to New.
func (w *Writer) Info(m string) errorNew 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) errorWarning logs a message with severity [LOG_WARNING], ignoring the severity passed to New.
func (w *Writer) Warning(m string) errorWrite sends a log message to the syslog daemon.
func (w *Writer) Write(b []byte) (int, error)func (n *netConn) close() errorconnect 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) errorGenerated with Arrow