syslog

Imports

Imports #

"errors"
"fmt"
"log"
"net"
"os"
"strings"
"sync"
"time"
"errors"
"net"

Constants & Variables

LOG_ALERT const #

const LOG_ALERT

LOG_AUTH const #

const LOG_AUTH

LOG_AUTHPRIV const #

const LOG_AUTHPRIV

LOG_CRIT const #

const LOG_CRIT

LOG_CRON const #

const LOG_CRON

LOG_DAEMON const #

const LOG_DAEMON

LOG_DEBUG const #

const LOG_DEBUG

LOG_EMERG const #

From /usr/include/sys/syslog.h. These are the same on Linux, BSD, and OS X.

const LOG_EMERG Priority = iota

LOG_ERR const #

const LOG_ERR

LOG_FTP const #

const LOG_FTP

LOG_INFO const #

const LOG_INFO

LOG_KERN const #

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

LOG_LOCAL0 const #

const LOG_LOCAL0

LOG_LOCAL1 const #

const LOG_LOCAL1

LOG_LOCAL2 const #

const LOG_LOCAL2

LOG_LOCAL3 const #

const LOG_LOCAL3

LOG_LOCAL4 const #

const LOG_LOCAL4

LOG_LOCAL5 const #

const LOG_LOCAL5

LOG_LOCAL6 const #

const LOG_LOCAL6

LOG_LOCAL7 const #

const LOG_LOCAL7

LOG_LPR const #

const LOG_LPR

LOG_MAIL const #

const LOG_MAIL

LOG_NEWS const #

const LOG_NEWS

LOG_NOTICE const #

const LOG_NOTICE

LOG_SYSLOG const #

const LOG_SYSLOG

LOG_USER const #

const LOG_USER

LOG_UUCP const #

const LOG_UUCP

LOG_WARNING const #

const LOG_WARNING

_ const #

const _

_ const #

const _

_ const #

const _

_ const #

const _

facilityMask const #

const facilityMask = 0xf8

severityMask const #

const severityMask = 0x07

Type Aliases

Priority type #

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

Interfaces

serverConn interface #

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
}

Structs

Writer struct #

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
}

netConn struct #

type netConn struct {
local bool
conn net.Conn
}

Functions

Alert method #

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

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

Close method #

Close closes a connection to the syslog daemon.

func (w *Writer) Close() error

Crit method #

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

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

Debug method #

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

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

Dial function #

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 method #

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

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

Err method #

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

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

Info method #

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

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

New function #

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 function #

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 method #

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

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

Warning method #

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

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

Write method #

Write sends a log message to the syslog daemon.

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

close method #

func (n *netConn) close() error

connect method #

connect makes a connection to the syslog server. It must be called with w.mu held.

func (w *Writer) connect() (err error)

unixSyslog function #

func unixSyslog() (conn serverConn, err error)

write method #

write generates and writes a syslog formatted string. The format is as follows: TIMESTAMP HOSTNAME TAG[PID]: MSG

func (w *Writer) write(p Priority, msg string) (int, error)

writeAndRetry method #

func (w *Writer) writeAndRetry(p Priority, s string) (int, error)

writeString method #

func (n *netConn) writeString(p Priority, hostname string, tag string, msg string, nl string) error

Generated with Arrow