(logMasks []config.LogMask)
| 91 | var replacers []regexReplacer |
| 92 | |
| 93 | func InitReplacer(logMasks []config.LogMask) error { |
| 94 | for _, logMask := range logMasks { |
| 95 | re, err := regexp.Compile(logMask.Regex) |
| 96 | if err != nil { |
| 97 | return fmt.Errorf("error compiling regex %s: %w", logMask.Regex, err) |
| 98 | } |
| 99 | replacers = append(replacers, regexReplacer{ |
| 100 | regex: re, |
| 101 | replacement: logMask.Replacement, |
| 102 | }) |
| 103 | } |
| 104 | return nil |
| 105 | } |
| 106 | |
| 107 | func mask(s string) string { |
| 108 | for _, r := range replacers { |
no outgoing calls