summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/v4/middleware/recover.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-09-04 23:29:13 +0200
committerGitHub <noreply@github.com>2020-09-04 23:29:13 +0200
commit2f59abdda7a1072036ea1fdb4c859cccbb56efa6 (patch)
treee35393f23d12783ae92f0469085efc7dec953f82 /vendor/github.com/labstack/echo/v4/middleware/recover.go
parent17747a5c8893fd47ba8eb61dd10477170640caf6 (diff)
downloadmatterbridge-msglm-2f59abdda7a1072036ea1fdb4c859cccbb56efa6.tar.gz
matterbridge-msglm-2f59abdda7a1072036ea1fdb4c859cccbb56efa6.tar.bz2
matterbridge-msglm-2f59abdda7a1072036ea1fdb4c859cccbb56efa6.zip
Update vendor (#1228)
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/middleware/recover.go')
-rw-r--r--vendor/github.com/labstack/echo/v4/middleware/recover.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/vendor/github.com/labstack/echo/v4/middleware/recover.go b/vendor/github.com/labstack/echo/v4/middleware/recover.go
index e87aaf32..0dbe740d 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/recover.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/recover.go
@@ -5,6 +5,7 @@ import (
"runtime"
"github.com/labstack/echo/v4"
+ "github.com/labstack/gommon/log"
)
type (
@@ -25,6 +26,10 @@ type (
// DisablePrintStack disables printing stack trace.
// Optional. Default value as false.
DisablePrintStack bool `yaml:"disable_print_stack"`
+
+ // LogLevel is log level to printing stack trace.
+ // Optional. Default value 0 (Print).
+ LogLevel log.Lvl
}
)
@@ -35,6 +40,7 @@ var (
StackSize: 4 << 10, // 4 KB
DisableStackAll: false,
DisablePrintStack: false,
+ LogLevel: 0,
}
)
@@ -70,7 +76,21 @@ func RecoverWithConfig(config RecoverConfig) echo.MiddlewareFunc {
stack := make([]byte, config.StackSize)
length := runtime.Stack(stack, !config.DisableStackAll)
if !config.DisablePrintStack {
- c.Logger().Printf("[PANIC RECOVER] %v %s\n", err, stack[:length])
+ msg := fmt.Sprintf("[PANIC RECOVER] %v %s\n", err, stack[:length])
+ switch config.LogLevel {
+ case log.DEBUG:
+ c.Logger().Debug(msg)
+ case log.INFO:
+ c.Logger().Info(msg)
+ case log.WARN:
+ c.Logger().Warn(msg)
+ case log.ERROR:
+ c.Logger().Error(msg)
+ case log.OFF:
+ // None.
+ default:
+ c.Logger().Print(msg)
+ }
}
c.Error(err)
}