Documentation
¶
Index ¶
- func APIKey(msg, r string) string
- func AWSAccessKey(msg, r string) string
- func BearerToken(msg, r string) string
- func CreditCard(msg, r string) string
- func Email(msg, r string) string
- func JWT(msg, r string) string
- func NewZerologWriter(w io.Writer, formatter *RedactingFormatter) io.Writer
- func Password(msg, r string) string
- func SSN(msg, r string) string
- func SetGlobalHashKey(key []byte)
- func SetGlobalRedactionCallback(cb func(redactorName, value string))
- type RedactingFormatter
- func (f *RedactingFormatter) AddRedactor(redactor RedactionFunc) *RedactingFormatter
- func (f *RedactingFormatter) AddRedactors(redactors ...RedactionFunc) *RedactingFormatter
- func (f *RedactingFormatter) Format(entry *logrus.Entry) ([]byte, error)
- func (f *RedactingFormatter) RedactFieldPatterns() []*regexp.Regexp
- func (f *RedactingFormatter) RedactFields(keys ...string) *RedactingFormatter
- func (f *RedactingFormatter) RedactFieldsByKeyPattern(patterns ...*regexp.Regexp) *RedactingFormatter
- func (f *RedactingFormatter) RedactFieldsList() []string
- func (f *RedactingFormatter) Redactors() []RedactionFunc
- func (f *RedactingFormatter) SetRedactWith(r string) *RedactingFormatter
- type RedactingHandler
- type RedactingWriter
- type RedactionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIKey ¶
APIKey redacts api_key, apikey, and api-key fields (case-insensitive) from a log message.
func AWSAccessKey ¶
AWSAccessKey redacts AWS Access Key ID and Secret Access Key from a log message.
func BearerToken ¶
BearerToken redacts Authorization Bearer tokens from a log message.
func CreditCard ¶
CreditCard redacts credit card numbers from a log message.
func NewZerologWriter ¶
func NewZerologWriter(w io.Writer, formatter *RedactingFormatter) io.Writer
NewZerologWriter returns an io.Writer that wraps the provided io.Writer with a RedactingWriter, enabling integration with Zerolog's writer-based output.
func Password ¶
Password redacts password, passwd, and pwd fields (case-insensitive) from a log message.
func SetGlobalHashKey ¶
func SetGlobalHashKey(key []byte)
SetGlobalHashKey configures the global hash key used for dynamic HMAC-SHA256 redaction.
func SetGlobalRedactionCallback ¶
func SetGlobalRedactionCallback(cb func(redactorName, value string))
SetGlobalRedactionCallback configures the global callback function invoked when a match is redacted.
Types ¶
type RedactingFormatter ¶
type RedactingFormatter struct {
InnerFormatter logrus.Formatter
RedactWith string
// contains filtered or unexported fields
}
RedactingFormatter struct that embeds logrus.Formatter and includes redaction functions. InnerFormatter and RedactWith are exported; redactors is unexported and protected by mu.
func NewDefaultRedactingFormatter ¶
func NewDefaultRedactingFormatter(innerFormatter logrus.Formatter) *RedactingFormatter
NewDefaultRedactingFormatter creates a new RedactingFormatter with default redactors.
func NewRedactingFormatter ¶
func NewRedactingFormatter(innerFormatter logrus.Formatter) *RedactingFormatter
NewRedactingFormatter creates a new RedactingFormatter with no redactors. RedactWith defaults to "[REDACTED]".
func (*RedactingFormatter) AddRedactor ¶
func (f *RedactingFormatter) AddRedactor(redactor RedactionFunc) *RedactingFormatter
AddRedactor adds a new redaction function to the RedactingFormatter.
func (*RedactingFormatter) AddRedactors ¶
func (f *RedactingFormatter) AddRedactors(redactors ...RedactionFunc) *RedactingFormatter
AddRedactors adds multiple redaction functions to the RedactingFormatter.
func (*RedactingFormatter) Format ¶
func (f *RedactingFormatter) Format(entry *logrus.Entry) ([]byte, error)
Format formats the log entry, applying all redaction functions to the output.
func (*RedactingFormatter) RedactFieldPatterns ¶
func (f *RedactingFormatter) RedactFieldPatterns() []*regexp.Regexp
RedactFieldPatterns returns a copy of the regex patterns configured for key-pattern field redaction.
func (*RedactingFormatter) RedactFields ¶
func (f *RedactingFormatter) RedactFields(keys ...string) *RedactingFormatter
RedactFields adds one or more specific field keys to be redacted from logrus entry fields.
func (*RedactingFormatter) RedactFieldsByKeyPattern ¶
func (f *RedactingFormatter) RedactFieldsByKeyPattern(patterns ...*regexp.Regexp) *RedactingFormatter
RedactFieldsByKeyPattern adds one or more regex patterns to match against entry field keys.
func (*RedactingFormatter) RedactFieldsList ¶
func (f *RedactingFormatter) RedactFieldsList() []string
RedactFieldsList returns a list of exact keys configured for field redaction.
func (*RedactingFormatter) Redactors ¶
func (f *RedactingFormatter) Redactors() []RedactionFunc
Redactors returns a copy of the current redactors slice for inspection or testing.
func (*RedactingFormatter) SetRedactWith ¶
func (f *RedactingFormatter) SetRedactWith(r string) *RedactingFormatter
SetRedactWith sets the string to redact sensitive information with.
type RedactingHandler ¶
type RedactingHandler struct {
// contains filtered or unexported fields
}
RedactingHandler wraps an slog.Handler and redacts matching attributes.
func NewRedactingHandler ¶
func NewRedactingHandler(h slog.Handler, formatter *RedactingFormatter) *RedactingHandler
NewRedactingHandler creates a new RedactingHandler.
func (*RedactingHandler) Handle ¶
Handle copies the record, redacts its attributes, and delegates to the inner handler.
type RedactingWriter ¶
type RedactingWriter struct {
// contains filtered or unexported fields
}
RedactingWriter wraps an io.Writer and applies string-level redactions to all written data.
func NewRedactingWriter ¶
func NewRedactingWriter(w io.Writer, formatter *RedactingFormatter) *RedactingWriter
NewRedactingWriter creates a new RedactingWriter with the given io.Writer and RedactingFormatter.
type RedactionFunc ¶
RedactionFunc type for functions that redact sensitive information
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
|
|
|
basic-with-text-formatter
command
|
|
|
custom-redactor
command
|
|
|
only-email
command
|