|
12 | 12 |
|
13 | 13 | Common formatters for [slog](https://pkg.go.dev/golang.org/x/exp/slog) library + helpers for building your own. |
14 | 14 |
|
| 15 | +**Handlers:** |
| 16 | +- [NewFormatterHandler](#NewFormatterHandler): main handler |
| 17 | +- [NewFormatterMiddleware](#NewFormatterMiddleware): compatible with `slog-multi` middlewares |
| 18 | + |
| 19 | +**Common formatters:** |
| 20 | +- [TimeFormatter](#TimeFormatter): transforms a `time.Time` into a readable string |
| 21 | +- [UnixTimestampFormatter](#UnixTimestampFormatter): transforms a `time.Time` into a unix timestamp. |
| 22 | +- [TimezoneConverter](#TimezoneConverter): set a `time.Time` to a different timezone |
| 23 | +- [ErrorFormatter](#ErrorFormatter): transforms a go error into a readable error |
| 24 | +- [HTTPRequestFormatter](#HTTPRequestFormatter-and-HTTPResponseFormatter): transforms a *http.Request into a readable object |
| 25 | +- [HTTPResponseFormatter](#HTTPRequestFormatter-and-HTTPResponseFormatter): transforms a *http.Response into a readable object |
| 26 | +- [PIIFormatter](#PIIFormatter): hide private Personal Identifiable Information (PII) |
| 27 | +- [IPAddressFormatter](#IPAddressFormatter): hide ip address from logs |
| 28 | + |
| 29 | +**Custom formatter:** |
| 30 | +- [Format](#Format): pass any attribute into a formatter |
| 31 | +- [FormatByKind](#FormatByKind): pass attributes matching `slog.Kind` into a formatter |
| 32 | +- [FormatByType](#FormatByType): pass attributes matching generic type into a formatter |
| 33 | +- [FormatByKey](#FormatByKey): pass attributes matching key into a formatter |
| 34 | +- [FormatByFieldType](#FormatByFieldType): pass attributes matching both key and generic type into a formatter |
| 35 | +- [FormatByGroup](#FormatByGroup): pass attributes under a group into a formatter |
| 36 | +- [FormatByGroupKey](#FormatByGroupKey): pass attributes under a group and matching key, into a formatter |
| 37 | +- [FormatByGroupKeyType](#FormatByGroupKeyType): pass attributes under a group, matching key and matching a generic type, into a formatter |
| 38 | + |
15 | 39 | **See also:** |
16 | 40 |
|
17 | 41 | - [slog-multi](https://github.com/samber/slog-multi): `slog.Handler` chaining, fanout, routing, failover, load balancing... |
@@ -88,30 +112,6 @@ logger.Error("a message", |
88 | 112 |
|
89 | 113 | GoDoc: [https://pkg.go.dev/github.com/samber/slog-formatter](https://pkg.go.dev/github.com/samber/slog-formatter) |
90 | 114 |
|
91 | | -**Handlers:** |
92 | | -- [NewFormatterHandler](#NewFormatterHandler): main handler |
93 | | -- [NewFormatterMiddleware](#NewFormatterMiddleware): compatible with `slog-multi` middlewares |
94 | | - |
95 | | -**Common formatters:** |
96 | | -- [TimeFormatter](#TimeFormatter): transforms a `time.Time` into a readable string |
97 | | -- [UnixTimestampFormatter](#UnixTimestampFormatter): transforms a `time.Time` into a unix timestamp. |
98 | | -- [TimezoneConverter](#TimezoneConverter): set a `time.Time` to a different timezone |
99 | | -- [ErrorFormatter](#ErrorFormatter): transforms a go error into a readable error |
100 | | -- [HTTPRequestFormatter](#HTTPRequestFormatter-and-HTTPResponseFormatter): transforms a *http.Request into a readable object |
101 | | -- [HTTPResponseFormatter](#HTTPRequestFormatter-and-HTTPResponseFormatter): transforms a *http.Response into a readable object |
102 | | -- [PIIFormatter](#PIIFormatter): hide private Personal Identifiable Information (PII) |
103 | | -- [IPAddressFormatter](#IPAddressFormatter): hide ip address from logs |
104 | | - |
105 | | -**Custom formatter:** |
106 | | -- [Format](#Format): pass any attribute into a formatter |
107 | | -- [FormatByKind](#FormatByKind): pass attributes matching `slog.Kind` into a formatter |
108 | | -- [FormatByType](#FormatByType): pass attributes matching generic type into a formatter |
109 | | -- [FormatByKey](#FormatByKey): pass attributes matching key into a formatter |
110 | | -- [FormatByFieldType](#FormatByFieldType): pass attributes matching both key and generic type into a formatter |
111 | | -- [FormatByGroup](#FormatByGroup): pass attributes under a group into a formatter |
112 | | -- [FormatByGroupKey](#FormatByGroupKey): pass attributes under a group and matching key, into a formatter |
113 | | -- [FormatByGroupKeyType](#FormatByGroupKeyType): pass attributes under a group, matching key and matching a generic type, into a formatter |
114 | | - |
115 | 115 | ### NewFormatterHandler |
116 | 116 |
|
117 | 117 | Returns a slog.Handler that applies formatters to. |
|
0 commit comments