File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,11 @@ package logger
2
2
3
3
import (
4
4
"context"
5
+ "log/slog"
5
6
"net/http"
6
7
"net/url"
7
8
8
9
"github.com/cappuccinotm/slogx"
9
- "log/slog"
10
10
)
11
11
12
12
// Option is a function that configures a Logger.
@@ -36,6 +36,21 @@ func WithLogFn(fn func(context.Context, *LogParts)) Option {
36
36
return func (l * Logger ) { l .logFn = fn }
37
37
}
38
38
39
+ // WithSanitizeHeaders sets a custom function to sanitize headers.
40
+ func WithSanitizeHeaders (fn func (http.Header ) map [string ]string ) Option {
41
+ return func (l * Logger ) { l .sanitizeHeadersFn = fn }
42
+ }
43
+
44
+ // WithSanitizeQuery sets a custom function to sanitize query parameters.
45
+ func WithSanitizeQuery (fn func (string ) string ) Option {
46
+ return func (l * Logger ) { l .sanitizeQueryFn = fn }
47
+ }
48
+
49
+ // WithMaskIP sets a custom function to mask IP addresses.
50
+ func WithMaskIP (fn func (string ) string ) Option {
51
+ return func (l * Logger ) { l .maskIPFn = fn }
52
+ }
53
+
39
54
// Log2Slog is the default log function that logs to slog.
40
55
func Log2Slog (ctx context.Context , parts * LogParts , logger * slog.Logger ) {
41
56
msg := "http server request"
You can’t perform that action at this time.
0 commit comments