logging

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package logging provides robust, structured logging capabilities for the application, including sensitive data scrubbing and audit logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Min

func Min(a, b int) int

Min returns the minimum of two integers.

func NewProductionLoggerWithScrubbing

func NewProductionLoggerWithScrubbing() (*zap.Logger, error)

NewProductionLoggerWithScrubbing creates a production logger with automatic scrubbing

func ProductionLoggerConfig

func ProductionLoggerConfig(_ *SensitiveDataScrubber) zap.Config

ProductionLoggerConfig creates a production-optimized logger configuration

func ScrubJSON

func ScrubJSON(input map[string]interface{}) map[string]interface{}

ScrubJSON is a convenience function using the global scrubber

func ScrubString

func ScrubString(input string) string

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

func (m *LoggerMiddleware) LogSafeDebug(ctx context.Context, message string, fields ...zap.Field)

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

func (m *LoggerMiddleware) LogSafeInfo(ctx context.Context, message string, fields ...zap.Field)

LogSafeInfo logs info with automatic scrubbing

func (*LoggerMiddleware) LogSafeWarn

func (m *LoggerMiddleware) LogSafeWarn(ctx context.Context, message string, fields ...zap.Field)

LogSafeWarn logs warning with automatic scrubbing

func (*LoggerMiddleware) WithContext

func (m *LoggerMiddleware) WithContext(ctx context.Context, fields ...zap.Field) *zap.Logger

WithContext adds structured logging context with automatic scrubbing

type ScrubbingCore

type ScrubbingCore struct {
	zapcore.Core
	// contains filtered or unexported fields
}

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.

func (*ScrubbingCore) With

func (c *ScrubbingCore) With(fields []zapcore.Field) zapcore.Core

With wraps the underlying core to preserve scrubbing behavior.

func (*ScrubbingCore) Write

func (c *ScrubbingCore) Write(entry zapcore.Entry, fields []zapcore.Field) error

Write implements zapcore.Core interface with scrubbing

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL