Better debug logging + unit tests

This commit is contained in:
Manu Mtz-Almeida
2015-05-09 03:34:43 +02:00
parent c391520654
commit b690611c38
5 changed files with 99 additions and 16 deletions

View File

@ -15,7 +15,7 @@ func IsDebugging() bool {
return ginMode == debugCode
}
func debugRoute(httpMethod, absolutePath string, handlers HandlersChain) {
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
if IsDebugging() {
nuHandlers := len(handlers)
handlerName := nameOfFunction(handlers[nuHandlers-1])
@ -28,3 +28,13 @@ func debugPrint(format string, values ...interface{}) {
debugLogger.Printf(format, values...)
}
}
func debugPrintWARNING() {
debugPrint("[WARNING] Running in DEBUG mode! Disable it before going production\n")
}
func debugPrintError(err error) {
if err != nil {
debugPrint("[ERROR] %v\n", err)
}
}