Documentation
¶
Overview ¶
Package logging provides multi-backend logging for connection events and application messages. Supports syslog, JSON file logging, and stdout (with optional JSON format).
Index ¶
- type ConnectionEvent
- type JSONLogger
- func (j *JSONLogger) Close() error
- func (j *JSONLogger) LogConnection(event ConnectionEvent)
- func (j *JSONLogger) LogError(msg string, fields map[string]interface{})
- func (j *JSONLogger) LogInfo(msg string, fields map[string]interface{})
- func (j *JSONLogger) LogWarning(msg string, fields map[string]interface{})
- type Logger
- type MultiLogger
- func (m *MultiLogger) Close() error
- func (m *MultiLogger) LogConnection(event ConnectionEvent)
- func (m *MultiLogger) LogError(msg string, fields map[string]interface{})
- func (m *MultiLogger) LogInfo(msg string, fields map[string]interface{})
- func (m *MultiLogger) LogWarning(msg string, fields map[string]interface{})
- type StdoutLogger
- func (s *StdoutLogger) Close() error
- func (s *StdoutLogger) LogConnection(event ConnectionEvent)
- func (s *StdoutLogger) LogError(msg string, fields map[string]interface{})
- func (s *StdoutLogger) LogInfo(msg string, fields map[string]interface{})
- func (s *StdoutLogger) LogWarning(msg string, fields map[string]interface{})
- type SyslogLogger
- func (s *SyslogLogger) Close() error
- func (s *SyslogLogger) LogConnection(event ConnectionEvent)
- func (s *SyslogLogger) LogError(msg string, fields map[string]interface{})
- func (s *SyslogLogger) LogInfo(msg string, fields map[string]interface{})
- func (s *SyslogLogger) LogWarning(msg string, fields map[string]interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionEvent ¶
type ConnectionEvent struct {
Timestamp time.Time `json:"timestamp"`
ListenerName string `json:"listener_name"`
Protocol string `json:"protocol"`
SourceIP string `json:"source_ip"`
SourcePort int `json:"source_port"`
TargetIP string `json:"target_ip"`
TargetPort int `json:"target_port"`
EventType string `json:"event_type"` // "open", "close"
BytesSent int64 `json:"bytes_sent"`
BytesReceived int64 `json:"bytes_received"`
PacketsSent int64 `json:"packets_sent,omitempty"` // UDP only
PacketsReceived int64 `json:"packets_received,omitempty"` // UDP only
Duration int64 `json:"duration_ms"` // milliseconds
Error string `json:"error,omitempty"`
}
ConnectionEvent represents a connection lifecycle event
type JSONLogger ¶
type JSONLogger struct {
// contains filtered or unexported fields
}
JSONLogger implements logging to a JSON file
func NewJSONLogger ¶
func NewJSONLogger(path string) (*JSONLogger, error)
NewJSONLogger creates a new JSON file logger
func (*JSONLogger) LogConnection ¶
func (j *JSONLogger) LogConnection(event ConnectionEvent)
LogConnection logs a connection event as JSON
func (*JSONLogger) LogError ¶
func (j *JSONLogger) LogError(msg string, fields map[string]interface{})
LogError logs an error message as JSON
func (*JSONLogger) LogInfo ¶
func (j *JSONLogger) LogInfo(msg string, fields map[string]interface{})
LogInfo logs an informational message as JSON
func (*JSONLogger) LogWarning ¶
func (j *JSONLogger) LogWarning(msg string, fields map[string]interface{})
LogWarning logs a warning message as JSON
type Logger ¶
type Logger interface {
LogConnection(event ConnectionEvent)
LogError(msg string, fields map[string]interface{})
LogInfo(msg string, fields map[string]interface{})
LogWarning(msg string, fields map[string]interface{})
Close() error
}
Logger defines the interface for logging connection events and messages
type MultiLogger ¶
type MultiLogger struct {
// contains filtered or unexported fields
}
MultiLogger supports multiple logging backends simultaneously
func NewMultiLogger ¶
func NewMultiLogger(cfg config.LoggingConfig) (*MultiLogger, error)
NewMultiLogger creates a logger that writes to multiple backends
func (*MultiLogger) LogConnection ¶
func (m *MultiLogger) LogConnection(event ConnectionEvent)
LogConnection logs a connection event to all backends
func (*MultiLogger) LogError ¶
func (m *MultiLogger) LogError(msg string, fields map[string]interface{})
LogError logs an error message to all backends
func (*MultiLogger) LogInfo ¶
func (m *MultiLogger) LogInfo(msg string, fields map[string]interface{})
LogInfo logs an informational message to all backends
func (*MultiLogger) LogWarning ¶
func (m *MultiLogger) LogWarning(msg string, fields map[string]interface{})
LogWarning logs a warning message to all backends
type StdoutLogger ¶
type StdoutLogger struct {
// contains filtered or unexported fields
}
StdoutLogger implements logging to stdout/stderr When running under systemd, this will automatically be captured by journald
func NewStdoutLogger ¶
func NewStdoutLogger(useJSON bool) *StdoutLogger
NewStdoutLogger creates a new stdout logger
func (*StdoutLogger) Close ¶
func (s *StdoutLogger) Close() error
Close is a no-op for stdout logger
func (*StdoutLogger) LogConnection ¶
func (s *StdoutLogger) LogConnection(event ConnectionEvent)
LogConnection logs a connection event
func (*StdoutLogger) LogError ¶
func (s *StdoutLogger) LogError(msg string, fields map[string]interface{})
LogError logs an error message
func (*StdoutLogger) LogInfo ¶
func (s *StdoutLogger) LogInfo(msg string, fields map[string]interface{})
LogInfo logs an informational message
func (*StdoutLogger) LogWarning ¶
func (s *StdoutLogger) LogWarning(msg string, fields map[string]interface{})
LogWarning logs a warning message
type SyslogLogger ¶
type SyslogLogger struct {
// contains filtered or unexported fields
}
SyslogLogger implements logging to syslog
func NewSyslogLogger ¶
func NewSyslogLogger(cfg config.SyslogConfig) (*SyslogLogger, error)
NewSyslogLogger creates a new syslog logger
func (*SyslogLogger) Close ¶
func (s *SyslogLogger) Close() error
Close closes the syslog connection
func (*SyslogLogger) LogConnection ¶
func (s *SyslogLogger) LogConnection(event ConnectionEvent)
LogConnection logs a connection event
func (*SyslogLogger) LogError ¶
func (s *SyslogLogger) LogError(msg string, fields map[string]interface{})
LogError logs an error message
func (*SyslogLogger) LogInfo ¶
func (s *SyslogLogger) LogInfo(msg string, fields map[string]interface{})
LogInfo logs an informational message
func (*SyslogLogger) LogWarning ¶
func (s *SyslogLogger) LogWarning(msg string, fields map[string]interface{})
LogWarning logs a warning message