filtered

package
v0.0.0-...-b349366 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultSensitiveFilter is a Filter that filters most sensitive data and
	// replaces it with `<elided>`. These fields are filtered:
	// token, access_token, refresh_token, key, password, code
	DefaultSensitiveFilter = FilterSensitive(defaultSensitive, defaultElided)

	// QueryFilter filters maps at the fields with the name 'query', using the same rules as
	// DefaultSensitiveFilter
	DefaultQueryFilter = RestrictFilter("query", LowerCaseFilter(MapFilter(SliceFilter(DefaultSensitiveFilter))))
)

Functions

This section is empty.

Types

type Filter

type Filter interface {
	Filter(string, interface{}) interface{}
}

A Filter is something that can filter a field value

func FilterSensitive

func FilterSensitive(sensitive []string, elided interface{}) Filter

FilterSensitive creates a Filter that filters most sensitive data like passwords, keys, access_tokens, etc. and replaces them with the elided value

func LowerCaseFilter

func LowerCaseFilter(filter Filter) Filter

LowerCaseFilter creates a filter that only get passed lowercase field names

func MapFilter

func MapFilter(filter Filter) Filter

MapFilter lifts the filter to also work on maps. It loses the type information of the map fields

func RestrictFilter

func RestrictFilter(fieldName string, filter Filter) Filter

RestrictFilter restricts the filter to only work on a certain field

func SliceFilter

func SliceFilter(filter Filter) Filter

SliceFilter lifts the filter to also work on slices. It loses the type information of the slice elements

type FilterFunc

type FilterFunc func(string, interface{}) interface{}

A FilterFunc is a function that implements the Filter interface

func (FilterFunc) Filter

func (fn FilterFunc) Filter(k string, v interface{}) interface{}

Filter implements the Filter interface for FilterFuncs

type Filtered

type Filtered struct {
	log.Interface
	// contains filtered or unexported fields
}

Filtered is a logger that filters the fields it receives

func Wrap

func Wrap(logger log.Interface, filters ...Filter) *Filtered

Wrap wraps an existing logger, filtering the fields as it goes along using the provided filters

func (*Filtered) WithField

func (f *Filtered) WithField(k string, v interface{}) log.Interface

WithField filters the field and passes it on to the wrapped loggers WithField

func (*Filtered) WithFields

func (f *Filtered) WithFields(fields log.Fields) log.Interface

WithFields filters the fields and passes them on to the wrapped loggers WithFields

func (*Filtered) WithFilters

func (f *Filtered) WithFilters(filters ...Filter) *Filtered

WithFilter creates a new Filtered that will use the extra filters

Jump to

Keyboard shortcuts

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