Documentation
¶
Overview ¶
Package logging provides robust, structured logging capabilities for the application, including sensitive data scrubbing and audit logging.
Index ¶
- func Min(a, b int) int
- func NewProductionLoggerWithScrubbing() (*zap.Logger, error)
- func ProductionLoggerConfig(_ *SensitiveDataScrubber) zap.Config
- func ScrubJSON(input map[string]interface{}) map[string]interface{}
- func ScrubString(input string) string
- type AuditLogger
- func (a *AuditLogger) LogAuthenticationEvent(_ context.Context, _ string, userID string, success bool, ...)
- func (a *AuditLogger) LogAuthorizationEvent(_ context.Context, action string, resource string, userID string, granted bool, ...)
- func (a *AuditLogger) LogSecurityEvent(_ context.Context, eventType string, severity string, description string, ...)
- type LoggerMiddleware
- func (m *LoggerMiddleware) LogSafeDebug(ctx context.Context, message string, fields ...zap.Field)
- func (m *LoggerMiddleware) LogSafeError(ctx context.Context, message string, err error, fields ...zap.Field)
- func (m *LoggerMiddleware) LogSafeInfo(ctx context.Context, message string, fields ...zap.Field)
- func (m *LoggerMiddleware) LogSafeWarn(ctx context.Context, message string, fields ...zap.Field)
- func (m *LoggerMiddleware) WithContext(ctx context.Context, fields ...zap.Field) *zap.Logger
- type ScrubbingCore
- func (c *ScrubbingCore) Check(entry zapcore.Entry, checkedEntry *zapcore.CheckedEntry) *zapcore.CheckedEntry
- func (c *ScrubbingCore) Enabled(level zapcore.Level) bool
- func (c *ScrubbingCore) Sync() error
- func (c *ScrubbingCore) With(fields []zapcore.Field) zapcore.Core
- func (c *ScrubbingCore) Write(entry zapcore.Entry, fields []zapcore.Field) error
- type SensitiveDataScrubber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProductionLoggerWithScrubbing ¶
NewProductionLoggerWithScrubbing creates a production logger with automatic scrubbing
func ProductionLoggerConfig ¶
func ProductionLoggerConfig(_ *SensitiveDataScrubber) zap.Config
ProductionLoggerConfig creates a production-optimized logger configuration
func ScrubString ¶
ScrubString is a convenience function using the global scrubber
Types ¶
type AuditLogger ¶
type AuditLogger struct {
// contains filtered or unexported fields
}
AuditLogger provides enhanced audit logging for security events
func NewAuditLogger ¶
func NewAuditLogger(logger *zap.Logger, scrubber *SensitiveDataScrubber) *AuditLogger
NewAuditLogger creates a new audit logger
func (*AuditLogger) LogAuthenticationEvent ¶
func (a *AuditLogger) LogAuthenticationEvent(_ context.Context, _ string, userID string, success bool, metadata map[string]interface{})
LogAuthenticationEvent logs an authentication event
func (*AuditLogger) LogAuthorizationEvent ¶
func (a *AuditLogger) LogAuthorizationEvent(_ context.Context, action string, resource string, userID string, granted bool, reason string)
LogAuthorizationEvent logs an authorization event
func (*AuditLogger) LogSecurityEvent ¶
func (a *AuditLogger) LogSecurityEvent(_ context.Context, eventType string, severity string, description string, metadata map[string]interface{})
LogSecurityEvent logs a generic security event
type LoggerMiddleware ¶
type LoggerMiddleware struct {
// contains filtered or unexported fields
}
LoggerMiddleware provides context-aware logging with automatic scrubbing
func NewLoggerMiddleware ¶
func NewLoggerMiddleware(logger *zap.Logger, scrubber *SensitiveDataScrubber) *LoggerMiddleware
NewLoggerMiddleware creates a new logger middleware
func (*LoggerMiddleware) LogSafeDebug ¶
LogSafeDebug logs debug info with automatic scrubbing
func (*LoggerMiddleware) LogSafeError ¶
func (m *LoggerMiddleware) LogSafeError(ctx context.Context, message string, err error, fields ...zap.Field)
LogSafeError logs an error with automatic scrubbing of sensitive data
func (*LoggerMiddleware) LogSafeInfo ¶
LogSafeInfo logs info with automatic scrubbing
func (*LoggerMiddleware) LogSafeWarn ¶
LogSafeWarn logs warning with automatic scrubbing
func (*LoggerMiddleware) WithContext ¶
WithContext adds structured logging context with automatic scrubbing
type ScrubbingCore ¶
ScrubbingCore wraps a zapcore.Core to automatically scrub sensitive data
func NewScrubbingCore ¶
func NewScrubbingCore(core zapcore.Core, scrubber *SensitiveDataScrubber) *ScrubbingCore
NewScrubbingCore creates a new core that automatically scrubs logs
func (*ScrubbingCore) Check ¶
func (c *ScrubbingCore) Check(entry zapcore.Entry, checkedEntry *zapcore.CheckedEntry) *zapcore.CheckedEntry
Check ensures the scrubbing core is the one that gets written.
func (*ScrubbingCore) Enabled ¶
func (c *ScrubbingCore) Enabled(level zapcore.Level) bool
Enabled passes through to the underlying core.
func (*ScrubbingCore) Sync ¶
func (c *ScrubbingCore) Sync() error
Sync passes through to the underlying core.
type SensitiveDataScrubber ¶
type SensitiveDataScrubber struct {
// contains filtered or unexported fields
}
SensitiveDataScrubber handles detection and redaction of sensitive information in logs
func GetGlobalScrubber ¶
func GetGlobalScrubber() *SensitiveDataScrubber
GetGlobalScrubber returns the global scrubber instance
func NewSensitiveDataScrubber ¶
func NewSensitiveDataScrubber() *SensitiveDataScrubber
NewSensitiveDataScrubber creates a new scrubber with comprehensive sensitive data patterns
func (*SensitiveDataScrubber) Disable ¶
func (s *SensitiveDataScrubber) Disable()
Disable turns off scrubbing
func (*SensitiveDataScrubber) Enable ¶
func (s *SensitiveDataScrubber) Enable()
Enable turns on scrubbing
func (*SensitiveDataScrubber) IsEnabled ¶
func (s *SensitiveDataScrubber) IsEnabled() bool
IsEnabled returns whether scrubbing is enabled
func (*SensitiveDataScrubber) ScrubJSON ¶
func (s *SensitiveDataScrubber) ScrubJSON(input map[string]interface{}) map[string]interface{}
ScrubJSON scrubs sensitive data from JSON objects
func (*SensitiveDataScrubber) ScrubString ¶
func (s *SensitiveDataScrubber) ScrubString(input string) string
ScrubString removes sensitive data from a string