syslog

package
v0.0.0-...-ffa646e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright (c) 2013 Paul Morton, Papertrail, Inc., & Paul Hammond

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2013 Paul Morton, Papertrail, Inc., & Paul Hammond

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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.

Copyright (c) 2013 Paul Morton, Papertrail, Inc., & Paul Hammond

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const ServerPollingInterval = 5 * time.Second

Variables

View Source
var ErrPriority = fmt.Errorf("Not a designated priority")

Returned when looking up a non-existant facility or severity

Functions

func NewDrainer

func NewDrainer(errorLogger *log.Logger, drain Drain, hostname, structuredData string) (*drainer, error)

Types

type Drain

type Drain struct {
	Transport string `yaml:"transport"`
	Address   string `yaml:"address"`
	CA        string `yaml:"ca"`
}

type Drainer

type Drainer interface {
	Drain(line string, tag string) error
}

type Logger

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

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

func (l *Logger) Close() error

func (*Logger) Write

func (l *Logger) Write(packet Packet)

type Packet

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

A Packet represents an RFC5424 syslog message

func Parse

func Parse(line string) (Packet, error)

A convenience function for testing

func (Packet) Generate

func (p Packet) Generate(max_size int) string

Generate creates a RFC5424 syslog format string for this packet.

func (Packet) Priority

func (p Packet) Priority() Priority

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

type Priority

type Priority int

A Syslog Priority is a combination of Severity and Facility.

const (
	SevEmerg Priority = iota
	SevAlert
	SevCrit
	SevErr
	SevWarning
	SevNotice
	SevInfo
	SevDebug
)

RFC5424 Severities

const (
	LogKern Priority = 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

func Facility

func Facility(name string) (Priority, error)

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

func Severity

func Severity(name string) (Priority, error)

Severity returns the named severity. It returns ErrPriority if the severity does not exist.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL