Documentation
¶
Index ¶
Constants ¶
const ( DISCONNECTED = iota CONNECTED CONNECTING )
connection status
const (
LOGGER_REMOTE = "remote"
)
const (
LOGGER_REMOTE_SYSLOG = "remote_syslog"
)
const (
LOGGER_SYSLOG = "syslog"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
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
// ConnectTimeout ...
ConnectTimeout string
// Tag: opensnitchd, mytag, ...
Tag string
// Workers: number of workers
Workers int
// MaxConnectAttempts holds the max attemps to connect to the remote server.
// A value of 0 will try to connect indefinitely.
MaxConnectAttempts uint16
}
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)
Load loggers configuration and initialize them.
func (*LoggerManager) Log ¶
func (l *LoggerManager) Log(args ...interface{})
Log sends data to the loggers.
func (*LoggerManager) Reload ¶
func (l *LoggerManager) Reload()
Reload stops and loads the configured loggers again
func (*LoggerManager) Stop ¶
func (l *LoggerManager) Stop()
Stop closes the opened loggers, and closes the workers
type Remote ¶
type Remote struct {
Writer *syslog.Writer
// Name of the logger
Name string
Tag string
// Name of the host where the daemon is running
Hostname string
// Write timeouts
Timeout time.Duration
// Connect timeout
ConnectTimeout time.Duration
// contains filtered or unexported fields
}
Remote defines a logger that writes events to a generic remote server. It can write to a 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 server, with the given format (RFC5424 by default)
func (*Remote) Open ¶
Open establishes a connection with a remote server. It'll try to reopen the connection based on the configuration provided: If MaxConnectAttempts is 0, indefinitely. Otherwise the amount of attempts specified.
type RemoteSyslog ¶
type RemoteSyslog struct {
*Remote
}
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)
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)