From e2adae90033ee85ec093b181089a722a8fa541f1 Mon Sep 17 00:00:00 2001
From: Manu Mtz-Almeida <manu.valladolid@gmail.com>
Date: Sun, 24 May 2015 01:00:17 +0200
Subject: [PATCH] Solution for Google App Engine?

https://cloud.google.com/appengine/docs/go/logs/
---
 debug.go      | 12 +++++-------
 debug_test.go | 17 +++--------------
 2 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/debug.go b/debug.go
index 47238928..7ac72d2c 100644
--- a/debug.go
+++ b/debug.go
@@ -4,13 +4,11 @@
 
 package gin
 
-import (
-	"log"
-	"os"
-)
-
-var debugLogger = log.New(os.Stdout, "[GIN-debug] ", 0)
+import "log"
 
+func init() {
+	log.SetFlags(0)
+}
 func IsDebugging() bool {
 	return ginMode == debugCode
 }
@@ -25,7 +23,7 @@ func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
 
 func debugPrint(format string, values ...interface{}) {
 	if IsDebugging() {
-		debugLogger.Printf(format, values...)
+		log.Printf("[GIN-debug] "+format, values...)
 	}
 }
 
diff --git a/debug_test.go b/debug_test.go
index 4e45f56a..425aff0f 100644
--- a/debug_test.go
+++ b/debug_test.go
@@ -9,13 +9,12 @@ import (
 	"errors"
 	"io"
 	"log"
+	"os"
 	"testing"
 
 	"github.com/stretchr/testify/assert"
 )
 
-var cachedDebugLogger *log.Logger = nil
-
 // TODO
 // func debugRoute(httpMethod, absolutePath string, handlers HandlersChain) {
 // func debugPrint(format string, values ...interface{}) {
@@ -60,20 +59,10 @@ func TestDebugPrintError(t *testing.T) {
 
 func setup(w io.Writer) {
 	SetMode(DebugMode)
-	if cachedDebugLogger == nil {
-		cachedDebugLogger = debugLogger
-		debugLogger = log.New(w, debugLogger.Prefix(), 0)
-	} else {
-		panic("setup failed")
-	}
+	log.SetOutput(w)
 }
 
 func teardown() {
 	SetMode(TestMode)
-	if cachedDebugLogger != nil {
-		debugLogger = cachedDebugLogger
-		cachedDebugLogger = nil
-	} else {
-		panic("teardown failed")
-	}
+	log.SetOutput(os.Stdout)
 }