Home / Function/ TestDefaultLogFormatter() — gin Function Reference

TestDefaultLogFormatter() — gin Function Reference

Architecture documentation for the TestDefaultLogFormatter() function in logger_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  49100f84_96bc_7caa_d0a8_921da273e61d["TestDefaultLogFormatter()"]
  9089ba1c_3991_2941_2a87_9934a9e12a6a["logger_test.go"]
  49100f84_96bc_7caa_d0a8_921da273e61d -->|defined in| 9089ba1c_3991_2941_2a87_9934a9e12a6a
  style 49100f84_96bc_7caa_d0a8_921da273e61d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

logger_test.go lines 234–285

func TestDefaultLogFormatter(t *testing.T) {
	timeStamp := time.Unix(1544173902, 0).UTC()

	termFalseParam := LogFormatterParams{
		TimeStamp:    timeStamp,
		StatusCode:   200,
		Latency:      time.Second * 5,
		ClientIP:     "20.20.20.20",
		Method:       http.MethodGet,
		Path:         "/",
		ErrorMessage: "",
		isTerm:       false,
	}

	termTrueParam := LogFormatterParams{
		TimeStamp:    timeStamp,
		StatusCode:   200,
		Latency:      time.Second * 5,
		ClientIP:     "20.20.20.20",
		Method:       http.MethodGet,
		Path:         "/",
		ErrorMessage: "",
		isTerm:       true,
	}
	termTrueLongDurationParam := LogFormatterParams{
		TimeStamp:    timeStamp,
		StatusCode:   200,
		Latency:      time.Millisecond * 9876543210,
		ClientIP:     "20.20.20.20",
		Method:       http.MethodGet,
		Path:         "/",
		ErrorMessage: "",
		isTerm:       true,
	}

	termFalseLongDurationParam := LogFormatterParams{
		TimeStamp:    timeStamp,
		StatusCode:   200,
		Latency:      time.Millisecond * 9876543210,
		ClientIP:     "20.20.20.20",
		Method:       http.MethodGet,
		Path:         "/",
		ErrorMessage: "",
		isTerm:       false,
	}

	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 | 2743h29m0s |     20.20.20.20 | GET      \"/\"\n", defaultLogFormatter(termFalseLongDurationParam))

	assert.Equal(t, "[GIN] 2018/12/07 - 09:11:42 |\x1b[97;42m 200 \x1b[0m|\x1b[97;41m       5s \x1b[0m|     20.20.20.20 |\x1b[97;44m GET     \x1b[0m \"/\"\n", defaultLogFormatter(termTrueParam))
	assert.Equal(t, "[GIN] 2018/12/07 - 09:11:42 |\x1b[97;42m 200 \x1b[0m|\x1b[97;41m 2743h29m0s \x1b[0m|     20.20.20.20 |\x1b[97;44m GET     \x1b[0m \"/\"\n", defaultLogFormatter(termTrueLongDurationParam))
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestDefaultLogFormatter() do?
TestDefaultLogFormatter() is a function in the gin codebase, defined in logger_test.go.
Where is TestDefaultLogFormatter() defined?
TestDefaultLogFormatter() is defined in logger_test.go at line 234.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free