Documentation
¶
Overview ¶
Package logging provides structured logging functionality using Go's slog package. It supports both text and JSON output formats, configurable log levels, and context-aware logging for the scanorama application.
Index ¶
- func Debug(msg string, fields ...any)
- func Error(msg string, fields ...any)
- func ErrorDaemon(msg string, err error, fields ...any)
- func ErrorDatabase(msg string, err error, fields ...any)
- func ErrorDiscovery(msg, network string, err error, fields ...any)
- func ErrorScan(msg, target string, err error, fields ...any)
- func Info(msg string, fields ...any)
- func InfoDaemon(msg string, fields ...any)
- func InfoDatabase(msg string, fields ...any)
- func InfoDiscovery(msg, network string, fields ...any)
- func InfoScan(msg, target string, fields ...any)
- func SetDefault(logger *Logger)
- func Warn(msg string, fields ...any)
- type Config
- type LogFormat
- type LogLevel
- type Logger
- func (l *Logger) ErrorDaemon(msg string, err error, fields ...any)
- func (l *Logger) ErrorDatabase(msg string, err error, fields ...any)
- func (l *Logger) ErrorDiscovery(msg, network string, err error, fields ...any)
- func (l *Logger) ErrorScan(msg, target string, err error, fields ...any)
- func (l *Logger) InfoDaemon(msg string, fields ...any)
- func (l *Logger) InfoDatabase(msg string, fields ...any)
- func (l *Logger) InfoDiscovery(msg, network string, fields ...any)
- func (l *Logger) InfoScan(msg, target string, fields ...any)
- func (l *Logger) WithComponent(component string) *Logger
- func (l *Logger) WithContext(ctx context.Context) *Logger
- func (l *Logger) WithError(err error) *Logger
- func (l *Logger) WithFields(fields ...any) *Logger
- func (l *Logger) WithScanID(scanID string) *Logger
- func (l *Logger) WithTarget(target string) *Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorDaemon ¶
ErrorDaemon logs daemon-related errors using the default logger.
func ErrorDatabase ¶
ErrorDatabase logs database-related errors using the default logger.
func ErrorDiscovery ¶
ErrorDiscovery logs discovery-related errors using the default logger.
func InfoDaemon ¶
InfoDaemon logs daemon-related information using the default logger.
func InfoDatabase ¶
InfoDatabase logs database-related information using the default logger.
func InfoDiscovery ¶
InfoDiscovery logs discovery-related information using the default logger.
Types ¶
type Config ¶
type Config struct { Level LogLevel `yaml:"level" json:"level"` Format LogFormat `yaml:"format" json:"format"` Output string `yaml:"output" json:"output"` AddSource bool `yaml:"add_source" json:"add_source"` }
Config holds logging configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a default logging configuration.
type Logger ¶
Logger wraps slog.Logger with additional functionality.
func (*Logger) ErrorDaemon ¶
ErrorDaemon logs daemon-related errors.
func (*Logger) ErrorDatabase ¶
ErrorDatabase logs database-related errors.
func (*Logger) ErrorDiscovery ¶
ErrorDiscovery logs discovery-related errors.
func (*Logger) InfoDaemon ¶
InfoDaemon logs daemon-related information.
func (*Logger) InfoDatabase ¶
InfoDatabase logs database-related information.
func (*Logger) InfoDiscovery ¶
InfoDiscovery logs discovery-related information.
func (*Logger) WithComponent ¶
WithComponent adds a component field to the logger.
func (*Logger) WithContext ¶
WithContext adds context to the logger for structured logging.
func (*Logger) WithFields ¶
WithFields adds structured fields to the logger.
func (*Logger) WithScanID ¶
WithScanID adds a scan ID field to the logger.
func (*Logger) WithTarget ¶
WithTarget adds a target field to the logger.