Documentation
¶
Overview ¶
Package logging provides PII-safe logging functionality for applications. It includes automatic sanitization of personally identifiable information (PII) and structured logging capabilities.
Index ¶
- func Debug(format string, v ...interface{})
- func Error(format string, v ...interface{})
- func Fatal(format string, v ...interface{})
- func Info(format string, v ...interface{})
- func SetJSONOutput(enabled bool)
- func SetLevel(level LogLevel)
- func SetPrefix(prefix string)
- func Warn(format string, v ...interface{})
- type LogEntry
- type LogLevel
- type LogSanitizer
- func (ls *LogSanitizer) AddCustomPattern(name string, pattern string) error
- func (ls *LogSanitizer) Sanitize(message string) string
- func (ls *LogSanitizer) SanitizeStruct(data interface{}) map[string]interface{}
- func (ls *LogSanitizer) SetEmailMasking(enabled bool)
- func (ls *LogSanitizer) SetIPMasking(enabled bool)
- type Logger
- func (l *Logger) Debug(format string, v ...interface{})
- func (l *Logger) Error(format string, v ...interface{})
- func (l *Logger) Fatal(format string, v ...interface{})
- func (l *Logger) Info(format string, v ...interface{})
- func (l *Logger) SetJSONOutput(enabled bool)
- func (l *Logger) SetLevel(level LogLevel)
- func (l *Logger) SetPrefix(prefix string)
- func (l *Logger) Warn(format string, v ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(format string, v ...interface{})
Debug logs a debug message with PII sanitization
func Error ¶
func Error(format string, v ...interface{})
Error logs an error message with PII sanitization
func Fatal ¶
func Fatal(format string, v ...interface{})
Fatal logs a fatal message and exits the program
func Info ¶
func Info(format string, v ...interface{})
Info logs an informational message with PII sanitization
func SetJSONOutput ¶
func SetJSONOutput(enabled bool)
SetJSONOutput enables or disables JSON output for the default logger
func SetLevel ¶
func SetLevel(level LogLevel)
SetLevel sets the minimum log level for the default logger
Types ¶
type LogEntry ¶
type LogEntry struct {
Timestamp string `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
Source string `json:"source,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
LogEntry represents a structured log entry
type LogLevel ¶
type LogLevel int
LogLevel represents the severity level of a log message
const ( // DebugLevel logs are typically only enabled in development DebugLevel LogLevel = iota // InfoLevel logs are informational messages InfoLevel // WarnLevel logs are warning messages WarnLevel // ErrorLevel logs are error messages ErrorLevel // FatalLevel logs are fatal messages that will cause the program to exit FatalLevel )
type LogSanitizer ¶
type LogSanitizer struct {
// contains filtered or unexported fields
}
LogSanitizer sanitizes log messages to remove PII
func NewLogSanitizer ¶
func NewLogSanitizer() *LogSanitizer
NewLogSanitizer creates a new log sanitizer with default settings
func (*LogSanitizer) AddCustomPattern ¶
func (ls *LogSanitizer) AddCustomPattern(name string, pattern string) error
AddCustomPattern adds a custom pattern for sanitization
func (*LogSanitizer) Sanitize ¶
func (ls *LogSanitizer) Sanitize(message string) string
Sanitize removes or masks PII from a log message
func (*LogSanitizer) SanitizeStruct ¶
func (ls *LogSanitizer) SanitizeStruct(data interface{}) map[string]interface{}
SanitizeStruct sanitizes a struct by masking PII in string fields
func (*LogSanitizer) SetEmailMasking ¶
func (ls *LogSanitizer) SetEmailMasking(enabled bool)
SetEmailMasking enables or disables email masking
func (*LogSanitizer) SetIPMasking ¶
func (ls *LogSanitizer) SetIPMasking(enabled bool)
SetIPMasking enables or disables IP address masking
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger provides PII-safe logging functionality
var ( // DefaultLogger is the default logger instance DefaultLogger *Logger )
func (*Logger) SetJSONOutput ¶
SetJSONOutput enables or disables JSON output format