golog: github.com/chapsuk/golog/syslog Index | Files

package syslog

import "github.com/chapsuk/golog/syslog"

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 not accepting new features. Some external packages provide more functionality. See:

https://godoc.org/?q=syslog

Index

Package Files

doc.go syslog.go syslog_unix.go

func NewLogger Uses

func NewLogger(p Priority, logFlag int) (*log.Logger, error)

NewLogger creates a log.Logger whose output is written to the system log service with the specified priority. The logFlag argument is the flag set passed through to log.New to create the Logger.

type Priority Uses

type Priority int

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.

const (

    // From /usr/include/sys/syslog.h.
    // These are the same on Linux, BSD, and OS X.
    LOG_EMERG Priority = iota
    LOG_ALERT
    LOG_CRIT
    LOG_ERR
    LOG_WARNING
    LOG_NOTICE
    LOG_INFO
    LOG_DEBUG
)
const (

    // From /usr/include/sys/syslog.h.
    // These are the same up to LOG_FTP on Linux, BSD, and OS X.
    LOG_KERN Priority = iota << 3
    LOG_USER
    LOG_MAIL
    LOG_DAEMON
    LOG_AUTH
    LOG_SYSLOG
    LOG_LPR
    LOG_NEWS
    LOG_UUCP
    LOG_CRON
    LOG_AUTHPRIV
    LOG_FTP

    LOG_LOCAL0
    LOG_LOCAL1
    LOG_LOCAL2
    LOG_LOCAL3
    LOG_LOCAL4
    LOG_LOCAL5
    LOG_LOCAL6
    LOG_LOCAL7
)

type Writer Uses

type Writer struct {
    // contains filtered or unexported fields
}

A Writer is a connection to a syslog server.

func Dial Uses

func Dial(network, raddr string, priority Priority, tag string) (*Writer, 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 given facility, severity and tag. If network is empty, Dial will connect to the local syslog server.

func New Uses

func New(priority Priority, tag string) (*Writer, 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 and prefix.

func (*Writer) Alert Uses

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

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

func (*Writer) Close Uses

func (w *Writer) Close() error

Close closes a connection to the syslog daemon.

func (*Writer) Crit Uses

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

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

func (*Writer) Debug Uses

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

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

func (*Writer) Emerg Uses

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

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

func (*Writer) Err Uses

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

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

func (*Writer) Info Uses

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

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

func (*Writer) Notice Uses

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

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

func (*Writer) SetDeadLine Uses

func (w *Writer) SetDeadLine(t time.Time) error

SetDeadLine sets deadline for connection

func (*Writer) SetReadDeadLine Uses

func (w *Writer) SetReadDeadLine(t time.Time) error

SetReadDeadLine sets read deadline for connection

func (*Writer) SetWriteDeadLine Uses

func (w *Writer) SetWriteDeadLine(t time.Time) error

SetWriteDeadLine sets write deadline for connection

func (*Writer) Warning Uses

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

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

func (*Writer) Write Uses

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

Write sends a log message to the syslog daemon.

Bugs

This package is not implemented on Windows. As the syslog package is frozen, Windows users are encouraged to use a package outside of the standard library. For background, see https://golang.org/issue/1108.

This package is not implemented on Plan 9.

This package is not implemented on NaCl (Native Client).

Package syslog imports 8 packages (graph) and is imported by 1 packages. Updated 2017-09-17. Refresh now. Tools for package owners.