loggers

package
v0.0.0-...-2ec37ed Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DISCONNECTED = iota
	CONNECTED
	CONNECTING
)

connection status

View Source
const (
	LOGGER_REMOTE = "remote"
)
View Source
const (
	LOGGER_REMOTE_SYSLOG = "remote_syslog"
)
View Source
const (
	LOGGER_SYSLOG = "syslog"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Transform(...interface{}) string
	Write(string)
}

Logger is the common interface that every logger must met. Serves as a generic holder of different types of loggers.

type LoggerConfig

type LoggerConfig struct {
	// Name of the logger: syslog, elastic, ...
	Name string
	// Format: rfc5424, csv, json, ...
	Format string
	// Protocol: udp, tcp
	Protocol string
	// Server: 127.0.0.1:514
	Server string
	// WriteTimeout:
	WriteTimeout string
	// Tag: opensnitchd, mytag, ...
	Tag string
	// Workers: number of workers
	Workers int
}

LoggerConfig holds the configuration of a logger

type LoggerManager

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

LoggerManager represents the LoggerManager.

func NewLoggerManager

func NewLoggerManager() *LoggerManager

NewLoggerManager instantiates all the configured loggers.

func (*LoggerManager) Load

func (l *LoggerManager) Load(configs []LoggerConfig, workers int)

Load loggers configuration and initialize them.

func (*LoggerManager) Log

func (l *LoggerManager) Log(args ...interface{})

Log sends data to the loggers.

type Remote

type Remote struct {
	Writer *syslog.Writer

	Name     string
	Tag      string
	Hostname string
	Timeout  time.Duration
	// contains filtered or unexported fields
}

Remote defines the logger that writes events to a generic remote server. It can write to the local or a remote daemon, UDP or TCP. It supports writing events in RFC5424, RFC3164, CSV and JSON formats.

func NewRemote

func NewRemote(cfg *LoggerConfig) (*Remote, error)

NewRemote returns a new object that manipulates and prints outbound connections to a remote syslog server, with the given format (RFC5424 by default)

func (*Remote) Close

func (s *Remote) Close() (err error)

Close closes the writer object

func (*Remote) Dial

func (s *Remote) Dial(proto, addr string, connTimeout time.Duration) (netConn net.Conn, err error)

Dial opens a new connection with a remote server.

func (*Remote) Open

func (s *Remote) Open() (err error)

Open opens a new connection with a server or with the daemon.

func (*Remote) ReOpen

func (s *Remote) ReOpen()

ReOpen tries to reestablish the connection with the writer

func (*Remote) Transform

func (s *Remote) Transform(args ...interface{}) (out string)

Transform transforms data for proper ingestion.

func (*Remote) Write

func (s *Remote) Write(msg string)

type RemoteSyslog

type RemoteSyslog struct {
	Syslog

	Hostname string
	Timeout  time.Duration
	// contains filtered or unexported fields
}

RemoteSyslog defines the logger that writes traces to the syslog. It can write to the local or a remote daemon.

func NewRemoteSyslog

func NewRemoteSyslog(cfg *LoggerConfig) (*RemoteSyslog, error)

NewRemoteSyslog returns a new object that manipulates and prints outbound connections to a remote syslog server, with the given format (RFC5424 by default)

func (*RemoteSyslog) Close

func (s *RemoteSyslog) Close() (err error)

Close closes the writer object

func (*RemoteSyslog) Dial

func (s *RemoteSyslog) Dial(proto, addr string, connTimeout time.Duration) (netConn net.Conn, err error)

Dial opens a new connection with a syslog server.

func (*RemoteSyslog) Open

func (s *RemoteSyslog) Open() (err error)

Open opens a new connection with a server or with the daemon.

func (*RemoteSyslog) ReOpen

func (s *RemoteSyslog) ReOpen()

ReOpen tries to reestablish the connection with the writer

func (*RemoteSyslog) Transform

func (s *RemoteSyslog) Transform(args ...interface{}) (out string)

Transform transforms data for proper ingestion.

func (*RemoteSyslog) Write

func (s *RemoteSyslog) Write(msg string)

type Syslog

type Syslog struct {
	Writer *syslog.Writer

	Name string
	Tag  string
	// contains filtered or unexported fields
}

Syslog defines the logger that writes traces to the syslog. It can write to the local or a remote daemon.

func NewSyslog

func NewSyslog(cfg *LoggerConfig) (*Syslog, error)

NewSyslog returns a new object that manipulates and prints outbound connections to syslog (local or remote), with the given format (RFC5424 by default)

func (*Syslog) Close

func (s *Syslog) Close() error

Close closes the writer object

func (*Syslog) Open

func (s *Syslog) Open() error

Open opens a new connection with a server or with the daemon.

func (*Syslog) Transform

func (s *Syslog) Transform(args ...interface{}) (out string)

Transform transforms data for proper ingestion.

func (*Syslog) Write

func (s *Syslog) Write(msg string)

Jump to

Keyboard shortcuts

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