debug.go 669 B

12345678910111213141516171819202122232425
  1. // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
  2. // Use of this source code is governed by a MIT style
  3. // license that can be found in the LICENSE file.
  4. package gin
  5. import "log"
  6. func IsDebugging() bool {
  7. return ginMode == debugCode
  8. }
  9. func debugRoute(httpMethod, absolutePath string, handlers []HandlerFunc) {
  10. if IsDebugging() {
  11. nuHandlers := len(handlers)
  12. handlerName := nameOfFunction(handlers[nuHandlers-1])
  13. debugPrint("%-5s %-25s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers)
  14. }
  15. }
  16. func debugPrint(format string, values ...interface{}) {
  17. if IsDebugging() {
  18. log.Printf("[GIN-debug] "+format, values...)
  19. }
  20. }