Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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...)
}
}

Expand Down
5 changes: 2 additions & 3 deletions debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"bytes"
"errors"
"io"
"log"
"os"
"testing"

Expand Down Expand Up @@ -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)
}