Documentation
¶
Index ¶
- Constants
- type Logger
- type LoggerConfig
- type LoggerManager
- type Remote
- type RemoteSyslog
- func (s *RemoteSyslog) Close() (err error)
- func (s *RemoteSyslog) Dial(proto, addr string, connTimeout time.Duration) (netConn net.Conn, err error)
- func (s *RemoteSyslog) Open() (err error)
- func (s *RemoteSyslog) ReOpen()
- func (s *RemoteSyslog) Transform(args ...interface{}) (out string)
- func (s *RemoteSyslog) Write(msg string)
- type Syslog
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 }
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 string Tag string Hostname string Timeout time.Duration ConnectTimeout 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) ReOpen ¶
func (s *Remote) ReOpen()
ReOpen tries to reestablish the connection with the writer
type RemoteSyslog ¶
type RemoteSyslog struct { Syslog Hostname string Timeout time.Duration ConnectTimeout 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)