github.com/Scalingo/go-utils/logger v1.13.0
Go module source archive layoutArchive contains go.mod
SHA-25659baa00d60944c765c92a2062d586cce2a5ac7588ebda0496701a8de291e8386
MaleculeK(Te)H₃(CmDb₂Os)Md₂(In₂Pa₂)
Evidence
1package logger
2
3import (
4 "context"
5 "fmt"
6 "reflect"
7 "strings"
8
9 "github.com/sirupsen/logrus"
10 "gopkg.in/mgo.v2/bson"
11)
12
13type Loggable interface {
14 LogFields() logrus.Fields
15}
16
17// FieldsFor extracts loggable fields from a struct based on the "log" tag.
18// It returns a logrus.Fields map where the keys are the tag values prefixed
19// with the provided prefix, and the values are the corresponding field values.
20//
21// If the struct or a pointer to the struct i …
55:16… printf("%s_%s", prefix, k)] = v
56 }
57 return fields
58 }
59
60 val := reflect.Indirect(reflect.ValueOf(value))
61
62 if val.Kind() == reflect.Struct {
63 for i := 0; i < val.NumField(); i++ {
64 structField := v …
63:18… Formatter{
64 Formatter: &logrus.TextFormatter{},
65 fields: []*RedactionOption{
66 {
67 Field: "password",
⋯11 lines
108:10… .Equal(t, "time=\"0001-01-01T00:00:00Z\" level=panic example=\"[REDACTED]\"\n", string(got))
109 })
110
111 t.Run("single matching field is redacted with replacement text", func(t *testing.T) {
112 // Given
113 f := &RedactingFormatter{
114 Formatter: &l …
1package logger
2
3import (
4 "os"
5 "testing"
6
7 "github.com/sirupsen/logrus"
8 "github.com/stretchr/testify/assert"
9)
10
11func TestFormatter(t *testing.T) {
12 examples := []struct {
13 Name string
14 Env map[string]string
15 FormatterType interface{}
16 }{
17 {
18 Name: "with no environment",
19 FormatterType: &logrus.TextFormatter{},
20 }, {
21 Name: "with an i …
Showing the top 5 files — 2 more files (17 regions) not shown.
No evidence locations were recorded for this file. Raw result