mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-22 01:12:16 +08:00
change public property to private
This commit is contained in:
parent
bdd6c78d5b
commit
d6440ae249
@ -69,8 +69,8 @@ type LogFormatterParams struct {
|
|||||||
Path string
|
Path string
|
||||||
// ErrorMessage is set if error has occurred in processing the request.
|
// ErrorMessage is set if error has occurred in processing the request.
|
||||||
ErrorMessage string
|
ErrorMessage string
|
||||||
// IsTerm shows whether does gin's output descriptor refers to a terminal.
|
// isTerm shows whether does gin's output descriptor refers to a terminal.
|
||||||
IsTerm bool
|
isTerm bool
|
||||||
// BodySize is the size of the Response Body
|
// BodySize is the size of the Response Body
|
||||||
BodySize int
|
BodySize int
|
||||||
// Keys are the keys set on the request's context.
|
// Keys are the keys set on the request's context.
|
||||||
@ -124,7 +124,7 @@ func (p *LogFormatterParams) ResetColor() string {
|
|||||||
|
|
||||||
// IsOutputColor indicates whether can colors be outputted to the log.
|
// IsOutputColor indicates whether can colors be outputted to the log.
|
||||||
func (p *LogFormatterParams) IsOutputColor() bool {
|
func (p *LogFormatterParams) IsOutputColor() bool {
|
||||||
return consoleColorMode == forceColor || (consoleColorMode == autoColor && p.IsTerm)
|
return consoleColorMode == forceColor || (consoleColorMode == autoColor && p.isTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultLogFormatter is the default log format function Logger middleware uses.
|
// defaultLogFormatter is the default log format function Logger middleware uses.
|
||||||
@ -239,7 +239,7 @@ func LoggerWithConfig(conf LoggerConfig) HandlerFunc {
|
|||||||
if _, ok := skip[path]; !ok {
|
if _, ok := skip[path]; !ok {
|
||||||
param := LogFormatterParams{
|
param := LogFormatterParams{
|
||||||
Request: c.Request,
|
Request: c.Request,
|
||||||
IsTerm: isTerm,
|
isTerm: isTerm,
|
||||||
Keys: c.Keys,
|
Keys: c.Keys,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ func TestDefaultLogFormatter(t *testing.T) {
|
|||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: "/",
|
Path: "/",
|
||||||
ErrorMessage: "",
|
ErrorMessage: "",
|
||||||
IsTerm: false,
|
isTerm: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
termTrueParam := LogFormatterParams{
|
termTrueParam := LogFormatterParams{
|
||||||
@ -251,7 +251,7 @@ func TestDefaultLogFormatter(t *testing.T) {
|
|||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: "/",
|
Path: "/",
|
||||||
ErrorMessage: "",
|
ErrorMessage: "",
|
||||||
IsTerm: true,
|
isTerm: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, "[GIN] 2018/12/07 - 09:11:42 | 200 | 5s | 20.20.20.20 | GET /\n", defaultLogFormatter(termFalseParam))
|
assert.Equal(t, "[GIN] 2018/12/07 - 09:11:42 | 200 | 5s | 20.20.20.20 | GET /\n", defaultLogFormatter(termFalseParam))
|
||||||
@ -297,9 +297,9 @@ func TestResetColor(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIsOutputColor(t *testing.T) {
|
func TestIsOutputColor(t *testing.T) {
|
||||||
// test with IsTerm flag true.
|
// test with isTerm flag true.
|
||||||
p := LogFormatterParams{
|
p := LogFormatterParams{
|
||||||
IsTerm: true,
|
isTerm: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleColorMode = autoColor
|
consoleColorMode = autoColor
|
||||||
@ -311,9 +311,9 @@ func TestIsOutputColor(t *testing.T) {
|
|||||||
DisableConsoleColor()
|
DisableConsoleColor()
|
||||||
assert.Equal(t, false, p.IsOutputColor())
|
assert.Equal(t, false, p.IsOutputColor())
|
||||||
|
|
||||||
// test with IsTerm flag false.
|
// test with isTerm flag false.
|
||||||
p = LogFormatterParams{
|
p = LogFormatterParams{
|
||||||
IsTerm: false,
|
isTerm: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleColorMode = autoColor
|
consoleColorMode = autoColor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user