gsyslog

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: MIT Imports: 9 Imported by: 0

README

any-os-syslog

This repository provides a very simple gsyslog package. The point of this package is to allow safe importing of syslog without introducing cross-compilation issues. The stdlib log/syslog cannot be imported on Windows systems, and without conditional compilation this adds complications.

Instead, gsyslog provides a very simple wrapper around log/syslog. By default, it just prints out log messages on a non Linux or OSX system. You can change the destination of log messages (a file, a database, other logging system, etc) by setting custom writer, that implements io.Writer. You just need to use SetOtherWriter(io.Writer) method. (It does nothing on a Linux or OSX system).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Priority

type Priority int

Priority maps to the syslog priority levels

const (
	LOG_EMERG Priority = iota
	LOG_ALERT
	LOG_CRIT
	LOG_ERR
	LOG_WARNING
	LOG_NOTICE
	LOG_INFO
	LOG_DEBUG
)

type Syslogger

type Syslogger interface {
	// WriteLevel is used to write a message at a given level
	WriteLevel(Priority, string) error

	// Write is used to write a message at the default level
	Write([]byte) (int, error)

	// Close is used to close the connection to the logger
	Close() error

	SetOtherWriter(io.Writer)
}

Syslogger interface is used to write log messages to syslog

func DialLogger

func DialLogger(network, raddr string, p Priority, facility, tag string) (Syslogger, error)

DialLogger is used to construct a new Syslogger that establishes connection to remote syslog server

func NewLogger

func NewLogger(p Priority, facility, tag string) (Syslogger, error)

NewLogger is used to construct a new Syslogger

Jump to

Keyboard shortcuts

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