Skip to content

Commit c18c7ac

Browse files
authored
Update recover middleware page (#265)
* Add LogErrorFunc in RecoverConfig * Replace json to yaml in RecoverConfig
1 parent ce2612f commit c18c7ac

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

website/content/middleware/recover.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,33 @@ default values for `DisableStackAll` and `DisablePrintStack`.
3232
## Configuration
3333

3434
```go
35+
// LogErrorFunc defines a function for custom logging in the middleware.
36+
LogErrorFunc func(c echo.Context, err error, stack []byte) error
37+
3538
RecoverConfig struct {
3639
// Skipper defines a function to skip middleware.
3740
Skipper Skipper
3841

3942
// Size of the stack to be printed.
4043
// Optional. Default value 4KB.
41-
StackSize int `json:"stack_size"`
44+
StackSize int `yaml:"stack_size"`
4245

4346
// DisableStackAll disables formatting stack traces of all other goroutines
4447
// into buffer after the trace for the current goroutine.
4548
// Optional. Default value false.
46-
DisableStackAll bool `json:"disable_stack_all"`
49+
DisableStackAll bool `yaml:"disable_stack_all"`
4750

4851
// DisablePrintStack disables printing stack trace.
4952
// Optional. Default value as false.
50-
DisablePrintStack bool `json:"disable_print_stack"`
53+
DisablePrintStack bool `yaml:"disable_print_stack"`
5154

5255
// LogLevel is log level to printing stack trace.
5356
// Optional. Default value 0 (Print).
5457
LogLevel log.Lvl
58+
59+
// LogErrorFunc defines a function for custom logging in the middleware.
60+
// If it's set you don't need to provide LogLevel for config.
61+
LogErrorFunc LogErrorFunc
5562
}
5663
```
5764

@@ -64,5 +71,6 @@ DefaultRecoverConfig = RecoverConfig{
6471
DisableStackAll: false,
6572
DisablePrintStack: false,
6673
LogLevel: 0,
74+
LogErrorFunc: nil,
6775
}
6876
```

0 commit comments

Comments
 (0)