Documentation
¶
Overview ¶
Package logging provides structured logging for Typosentinel This package implements a comprehensive logging system with multiple outputs and formats
Index ¶
- type Format
- type Level
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(message string, fields ...interfaces.LogField)
- func (l *Logger) Error(message string, fields ...interfaces.LogField)
- func (l *Logger) ErrorWithErr(message string, err error, fields ...interfaces.LogField)
- func (l *Logger) Fatal(message string, fields ...interfaces.LogField)
- func (l *Logger) GetLevel() string
- func (l *Logger) GetStats() map[string]interface{}
- func (l *Logger) HealthCheck() error
- func (l *Logger) Info(message string, fields ...interfaces.LogField)
- func (l *Logger) Rotate() error
- func (l *Logger) SetLevel(level string) error
- func (l *Logger) Warn(message string, fields ...interfaces.LogField)
- func (l *Logger) WithContext(ctx context.Context) interfaces.Logger
- func (l *Logger) WithFields(fields ...interfaces.LogField) interfaces.Logger
- type Output
- type StructuredLogger
- func (sl *StructuredLogger) LogCacheOperation(ctx context.Context, operation, key string, hit bool, duration time.Duration, ...)
- func (sl *StructuredLogger) LogDatabaseOperation(ctx context.Context, operation, table string, duration time.Duration, ...)
- func (sl *StructuredLogger) LogMLOperation(ctx context.Context, operation string, inputSize int, confidence float64, ...)
- func (sl *StructuredLogger) LogPerformanceMetric(ctx context.Context, metricName string, value float64, unit string, ...)
- func (sl *StructuredLogger) LogRequest(ctx context.Context, method, path string, statusCode int, ...)
- func (sl *StructuredLogger) LogScanOperation(ctx context.Context, packageName, registry string, riskScore float64, ...)
- func (sl *StructuredLogger) LogSecurityEvent(ctx context.Context, eventType, description string, severity string, ...)
- func (sl *StructuredLogger) LogShutdown(ctx context.Context, reason string, fields ...interfaces.LogField)
- func (sl *StructuredLogger) LogStartup(ctx context.Context, fields ...interfaces.LogField)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger implements the interfaces.Logger interface
func NewLogger ¶
func NewLogger(cfg *config.LoggingConfig) (*Logger, error)
NewLogger creates a new logger instance
func (*Logger) Debug ¶
func (l *Logger) Debug(message string, fields ...interfaces.LogField)
Debug logs a debug message
func (*Logger) Error ¶
func (l *Logger) Error(message string, fields ...interfaces.LogField)
Error logs an error message
func (*Logger) ErrorWithErr ¶
func (l *Logger) ErrorWithErr(message string, err error, fields ...interfaces.LogField)
ErrorWithErr logs an error message with error details
func (*Logger) Fatal ¶
func (l *Logger) Fatal(message string, fields ...interfaces.LogField)
Fatal logs a fatal message and exits
func (*Logger) HealthCheck ¶
HealthCheck performs a health check on the logger
func (*Logger) Info ¶
func (l *Logger) Info(message string, fields ...interfaces.LogField)
Info logs an info message
func (*Logger) Warn ¶
func (l *Logger) Warn(message string, fields ...interfaces.LogField)
Warn logs a warning message
func (*Logger) WithContext ¶
func (l *Logger) WithContext(ctx context.Context) interfaces.Logger
WithContext returns a logger with context information
func (*Logger) WithFields ¶
func (l *Logger) WithFields(fields ...interfaces.LogField) interfaces.Logger
WithFields returns a logger with additional fields
type StructuredLogger ¶
type StructuredLogger struct {
*Logger
// contains filtered or unexported fields
}
StructuredLogger provides additional structured logging capabilities
func NewStructuredLogger ¶
func NewStructuredLogger(cfg *config.LoggingConfig, component, version string) (*StructuredLogger, error)
NewStructuredLogger creates a new structured logger with component information
func (*StructuredLogger) LogCacheOperation ¶
func (sl *StructuredLogger) LogCacheOperation(ctx context.Context, operation, key string, hit bool, duration time.Duration, fields ...interfaces.LogField)
LogCacheOperation logs a cache operation
func (*StructuredLogger) LogDatabaseOperation ¶
func (sl *StructuredLogger) LogDatabaseOperation(ctx context.Context, operation, table string, duration time.Duration, err error, fields ...interfaces.LogField)
LogDatabaseOperation logs a database operation
func (*StructuredLogger) LogMLOperation ¶
func (sl *StructuredLogger) LogMLOperation(ctx context.Context, operation string, inputSize int, confidence float64, duration time.Duration, err error, fields ...interfaces.LogField)
LogMLOperation logs a machine learning operation
func (*StructuredLogger) LogPerformanceMetric ¶
func (sl *StructuredLogger) LogPerformanceMetric(ctx context.Context, metricName string, value float64, unit string, fields ...interfaces.LogField)
LogPerformanceMetric logs a performance metric
func (*StructuredLogger) LogRequest ¶
func (sl *StructuredLogger) LogRequest(ctx context.Context, method, path string, statusCode int, duration time.Duration, fields ...interfaces.LogField)
LogRequest logs an HTTP request
func (*StructuredLogger) LogScanOperation ¶
func (sl *StructuredLogger) LogScanOperation(ctx context.Context, packageName, registry string, riskScore float64, duration time.Duration, err error, fields ...interfaces.LogField)
LogScanOperation logs a package scan operation
func (*StructuredLogger) LogSecurityEvent ¶
func (sl *StructuredLogger) LogSecurityEvent(ctx context.Context, eventType, description string, severity string, fields ...interfaces.LogField)
LogSecurityEvent logs a security-related event
func (*StructuredLogger) LogShutdown ¶
func (sl *StructuredLogger) LogShutdown(ctx context.Context, reason string, fields ...interfaces.LogField)
LogShutdown logs application shutdown information
func (*StructuredLogger) LogStartup ¶
func (sl *StructuredLogger) LogStartup(ctx context.Context, fields ...interfaces.LogField)
LogStartup logs application startup information