nomnomlog: github.com/shadowbq/nomnomlog/syslog Index | Files

package syslog

import "github.com/shadowbq/nomnomlog/syslog"

The syslog package provides a syslog client.

Unlike the core log/syslog package it uses the newer rfc5424 syslog protocol, reliably reconnects on failure, and supports TLS encrypted TCP connections.

Index

Package Files

facility.go packet.go priorities.go severity.go syslog.go

Variables

var ErrFacility = fmt.Errorf("Not a designated RFC5424 Facility")
var ErrSeverity = fmt.Errorf("Not a designated RFC5424 Severity")

Returned when looking up a non-existent facility or severity

func Facilitykeymap Uses

func Facilitykeymap(m map[string]Facility, value int) (key string, ok bool)

func Severitykeymap Uses

func Severitykeymap(m map[string]Severity, value int) (key string, ok bool)

Given the Hashmap severities and an Severity int it returns string of the Severity type

type Facility Uses

type Facility int
const (
    LogKern Facility = iota
    LogUser
    LogMail
    LogDaemon
    LogAuth
    LogSyslog
    LogLPR
    LogNews
    LogUUCP
    LogCron
    LogAuthPriv
    LogFTP
    LogNTP
    LogAudit
    LogAlert
    LogAt
    LogLocal0
    LogLocal1
    LogLocal2
    LogLocal3
    LogLocal4
    LogLocal5
    LogLocal6
    LogLocal7
)

RFC5424 Facilities iota represents successive untyped integer constants.

func FacilityMap Uses

func FacilityMap(name string) (Facility, error)

Facility returns the named facility. It returns ErrFacility if the facility does not exist.

func PriorityExtractFacility Uses

func PriorityExtractFacility(priority int) Facility

PriorityExtractSeverity returns the key severity from the priority.

type Logger Uses

type Logger struct {
    Packets        chan Packet
    Errors         chan error
    ClientHostname string
    // contains filtered or unexported fields
}

A Logger is a connection to a syslog server. It reconnects on error. Clients log by sending a Packet to the logger.Packets channel.

func Dial Uses

func Dial(clientHostname, network, raddr string, rootCAs *x509.CertPool, connectTimeout time.Duration, writeTimeout time.Duration, tcpMaxLineLength int) (*Logger, error)

Dial connects to the syslog server at raddr, using the optional certBundle, and launches a goroutine to watch logger.Packets for messages to log.

func (*Logger) Close Uses

func (l *Logger) Close() error

func (*Logger) Write Uses

func (l *Logger) Write(packet Packet)

type Packet Uses

type Packet struct {
    Severity Severity
    Facility Facility
    Hostname string
    Tag      string
    Time     time.Time
    Message  string
}

A Packet represents an RFC5425 syslog message

func Parse Uses

func Parse(line string) (Packet, error)

A convenience function for testing (Syslog.Parse)

func (Packet) Generate Uses

func (p Packet) Generate(max_size int) string

Generate creates a RFC5424 syslog format string for this packet.

func (Packet) Priority Uses

func (p Packet) Priority() Priority

The combined Facility and Severity of this packet. See RFC5424 for details.

type Priority Uses

type Priority int

type Severity Uses

type Severity int
const (
    SevEmerg Severity = iota
    SevAlert
    SevCrit
    SevErr
    SevWarning
    SevNotice
    SevInfo
    SevDebug
)

RFC5424 Severities iota represents successive untyped integer constants.

func PriorityExtractSeverity Uses

func PriorityExtractSeverity(priority int) Severity

PriorityExtractSeverity returns the key severity from the priority.

func SeverityMap Uses

func SeverityMap(name string) (Severity, error)

SeverityMap returns the int of the named severity as Severity type. It returns ErrSeverity if the severity does not exist.

Package syslog imports 9 packages (graph) and is imported by 1 packages. Updated 2019-01-07. Refresh now. Tools for package owners.