Let's user define how he wants to log his routes (eg. JSON, key value, or something else) (#1553) (#1555)

This commit is contained in:
Jérôme Laforge
2018-09-17 06:09:34 +02:00
committed by 田欧
parent 7c7f703cc5
commit 90c680ef5c
2 changed files with 51 additions and 1 deletions

View File

@ -20,11 +20,17 @@ func IsDebugging() bool {
return ginMode == debugCode
}
var DebugPrintRouteFunc func(httpMethod, absolutePath, handlerName string, nuHandlers int)
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
if IsDebugging() {
nuHandlers := len(handlers)
handlerName := nameOfFunction(handlers.Last())
debugPrint("%-6s %-25s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers)
if DebugPrintRouteFunc == nil {
debugPrint("%-6s %-25s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers)
} else {
DebugPrintRouteFunc(httpMethod, absolutePath, handlerName, nuHandlers)
}
}
}