From d36548bb5c4de4bfcf60ae6beb80d380aed8ece0 Mon Sep 17 00:00:00 2001 From: Robert Williamson Date: Sun, 5 Jun 2016 11:54:36 -0600 Subject: [PATCH] Replace uses of default/global log with package local instance. --- debug.go | 7 +++---- debug_test.go | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/debug.go b/debug.go index a121591a..4ece6a45 100644 --- a/debug.go +++ b/debug.go @@ -8,11 +8,10 @@ import ( "bytes" "html/template" "log" + "os" ) -func init() { - log.SetFlags(0) -} +var debugLog = log.New(os.Stderr, "[GIN-debug] ", 0) // IsDebugging returns true if the framework is running in 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{}) { if IsDebugging() { - log.Printf("[GIN-debug] "+format, values...) + debugLog.Printf(format, values...) } } diff --git a/debug_test.go b/debug_test.go index deceaa6e..e092b085 100644 --- a/debug_test.go +++ b/debug_test.go @@ -8,7 +8,6 @@ import ( "bytes" "errors" "io" - "log" "os" "testing" @@ -68,10 +67,10 @@ func TestDebugPrintRoutes(t *testing.T) { func setup(w io.Writer) { SetMode(DebugMode) - log.SetOutput(w) + debugLog.SetOutput(w) } func teardown() { SetMode(TestMode) - log.SetOutput(os.Stdout) + debugLog.SetOutput(os.Stderr) }