Replace uses of default/global log with package local instance.

This commit is contained in:
Robert Williamson 2016-06-05 11:54:36 -06:00
parent f931d1ea80
commit d36548bb5c
2 changed files with 5 additions and 7 deletions

View File

@ -8,11 +8,10 @@ import (
"bytes" "bytes"
"html/template" "html/template"
"log" "log"
"os"
) )
func init() { var debugLog = log.New(os.Stderr, "[GIN-debug] ", 0)
log.SetFlags(0)
}
// IsDebugging returns true if the framework is running in debug mode. // IsDebugging returns true if the framework is running in debug mode.
// Use SetMode(gin.Release) to switch to disable the debug mode. // Use SetMode(gin.Release) to switch to disable the debug mode.
@ -42,7 +41,7 @@ func debugPrintLoadTemplate(tmpl *template.Template) {
func debugPrint(format string, values ...interface{}) { func debugPrint(format string, values ...interface{}) {
if IsDebugging() { if IsDebugging() {
log.Printf("[GIN-debug] "+format, values...) debugLog.Printf(format, values...)
} }
} }

View File

@ -8,7 +8,6 @@ import (
"bytes" "bytes"
"errors" "errors"
"io" "io"
"log"
"os" "os"
"testing" "testing"
@ -68,10 +67,10 @@ func TestDebugPrintRoutes(t *testing.T) {
func setup(w io.Writer) { func setup(w io.Writer) {
SetMode(DebugMode) SetMode(DebugMode)
log.SetOutput(w) debugLog.SetOutput(w)
} }
func teardown() { func teardown() {
SetMode(TestMode) SetMode(TestMode)
log.SetOutput(os.Stdout) debugLog.SetOutput(os.Stderr)
} }