mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-24 02:32:17 +08:00
Testing travis - 3
This commit is contained in:
parent
59f75a54d0
commit
05daee8e88
41
debug.go
41
debug.go
@ -10,8 +10,6 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
)
|
)
|
||||||
@ -26,20 +24,37 @@ func IsDebugging() bool {
|
|||||||
return ginMode == debugCode
|
return ginMode == debugCode
|
||||||
}
|
}
|
||||||
|
|
||||||
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
|
func getTerminalSize() int {
|
||||||
if IsDebugging() {
|
width := 100
|
||||||
s := "<<<<<<<\tHandlers Running\t>>>>>>>"
|
if terminal.IsTerminal(int(os.Stdout.Fd())) {
|
||||||
w := 100
|
w, _, err := terminal.GetSize(int(os.Stdout.Fd()))
|
||||||
|
if err != nil {
|
||||||
if terminal.IsTerminal(int(os.Stdout.Fd())) {
|
|
||||||
w, _, _ = terminal.GetSize(int(os.Stdout.Fd()))
|
|
||||||
w -= 25
|
|
||||||
} else {
|
|
||||||
debugPrint("Couldn't get terminal size. Using default value...\n")
|
debugPrint("Couldn't get terminal size. Using default value...\n")
|
||||||
}
|
}
|
||||||
|
width = w - 25
|
||||||
|
}
|
||||||
|
return width
|
||||||
|
}
|
||||||
|
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
|
||||||
|
if IsDebugging() {
|
||||||
|
s := "<<<<<<<\tRunning Handlers\t>>>>>>>"
|
||||||
|
w := getTerminalSize()
|
||||||
|
|
||||||
debugPrint(fmt.Sprintf("%%%ds\n", w/2), s)
|
debugPrint(fmt.Sprintf("%%%ds\n", w/2), s)
|
||||||
for i := 0; i < len(handlers); i += 2 {
|
if len(handlers)%2 == 0 {
|
||||||
debugPrint("| %-50s | %-50s |\n", runtime.FuncForPC(reflect.ValueOf(handlers[i]).Pointer()).Name(), runtime.FuncForPC(reflect.ValueOf(handlers[i+1]).Pointer()).Name())
|
for i := 0; i < len(handlers); i += 2 {
|
||||||
|
first := nameOfFunction(handlers[i])
|
||||||
|
second := nameOfFunction(handlers[i+1])
|
||||||
|
debugPrint("| %-50s | %-50s |\n", first, second)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for i := 0; i < len(handlers)-1; i += 2 {
|
||||||
|
first := nameOfFunction(handlers[i])
|
||||||
|
second := nameOfFunction(handlers[i+1])
|
||||||
|
debugPrint("| %-50s | %-50s |\n", first, second)
|
||||||
|
}
|
||||||
|
last := nameOfFunction(handlers.Last())
|
||||||
|
debugPrint("| %-50s |\n", last)
|
||||||
}
|
}
|
||||||
nuHandlers := len(handlers)
|
nuHandlers := len(handlers)
|
||||||
debugPrint("Total %d handlers found...\n\n", nuHandlers)
|
debugPrint("Total %d handlers found...\n\n", nuHandlers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user