mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-24 02:32:17 +08:00
Merge d36548bb5c4de4bfcf60ae6beb80d380aed8ece0 into 79478c0e805b7757f0e69390b72707f14373343b
This commit is contained in:
commit
95ffb8e7f9
7
debug.go
7
debug.go
@ -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 disable debug mode.
|
// Use SetMode(gin.Release) to disable 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...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -106,10 +105,10 @@ func TestDebugPrintWARNINGNew(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)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user