gin/debug.go

31 lines
730 B
Go
Raw Normal View History

2015-03-23 05:03:12 +00:00
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package gin
2015-04-08 00:58:35 +00:00
import (
"log"
"os"
)
var debugLogger = log.New(os.Stdout, "[GIN-debug] ", 0)
2015-03-23 05:03:12 +00:00
func IsDebugging() bool {
2015-04-07 10:27:23 +00:00
return ginMode == debugCode
2015-03-23 05:03:12 +00:00
}
func debugRoute(httpMethod, absolutePath string, handlers []HandlerFunc) {
if IsDebugging() {
nuHandlers := len(handlers)
handlerName := nameOfFunction(handlers[nuHandlers-1])
debugPrint("%-5s %-25s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers)
}
}
func debugPrint(format string, values ...interface{}) {
if IsDebugging() {
2015-04-08 00:58:35 +00:00
debugLogger.Printf(format, values...)
2015-03-23 05:03:12 +00:00
}
}