logging

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package logging provides structured logging with PII redaction for gpd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...Field)

Debug logs a debug message using the default logger.

func Error

func Error(msg string, fields ...Field)

Error logs an error message using the default logger.

func Info

func Info(msg string, fields ...Field)

Info logs an info message using the default logger.

func SetDefault

func SetDefault(l *Logger)

SetDefault sets the default logger.

func Warn

func Warn(msg string, fields ...Field)

Warn logs a warning message using the default logger.

Types

type Field

type Field struct {
	Key   string
	Value interface{}
	PII   bool // Mark as PII for redaction
}

Field represents a log field.

func Bool

func Bool(key string, value bool) Field

Bool creates a boolean field.

func Duration

func Duration(key string, value time.Duration) Field

Duration creates a duration field.

func Err

func Err(err error) Field

Err creates an error field.

func Int

func Int(key string, value int) Field

Int creates an integer field.

func Int64

func Int64(key string, value int64) Field

Int64 creates an int64 field.

func Sensitive

func Sensitive(key string, value interface{}) Field

Sensitive creates a field marked as PII.

func String

func String(key, value string) Field

String creates a string field.

type Level

type Level int

Level represents a log level.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
)

func (Level) String

func (l Level) String() string

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger provides structured logging with PII redaction.

func NewLogger

func NewLogger(w io.Writer, verbose bool) *Logger

NewLogger creates a new logger.

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...Field)

Debug logs a debug message.

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...Field)

Error logs an error message.

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...Field)

Info logs an info message.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the minimum log level.

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...Field)

Warn logs a warning message.

type PIIRedactor

type PIIRedactor struct {
	// contains filtered or unexported fields
}

PIIRedactor handles PII redaction in log output.

func NewPIIRedactor

func NewPIIRedactor() *PIIRedactor

NewPIIRedactor creates a new PII redactor.

func (*PIIRedactor) IsAllowedField

func (r *PIIRedactor) IsAllowedField(key string) bool

IsAllowedField checks if a field is safe to log.

func (*PIIRedactor) IsSensitiveField

func (r *PIIRedactor) IsSensitiveField(key string) bool

IsSensitiveField checks if a field is sensitive.

func (*PIIRedactor) Redact

func (r *PIIRedactor) Redact(key string, value interface{}) interface{}

Redact redacts sensitive data from a value.

func (*PIIRedactor) RedactMap

func (r *PIIRedactor) RedactMap(data map[string]interface{}) map[string]interface{}

RedactMap redacts all sensitive fields in a map.

Jump to

Keyboard shortcuts

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