Add ability to customize upstream and stream log format

This commit is contained in:
Giancarlo Rubio 2017-02-27 11:00:31 +01:00
parent fb8e2d7373
commit 0ca3aef0f5
4 changed files with 72 additions and 11 deletions

View file

@ -0,0 +1,27 @@
package config
import (
"fmt"
"testing"
)
func TestBuildLogFormatUpstream(t *testing.T) {
testCases := []struct {
useProxyProtocol bool // use proxy protocol
expected string
}{
{true, fmt.Sprintf(logFormatUpstream, "$proxy_protocol_addr")},
{false, fmt.Sprintf(logFormatUpstream, "$remote_addr")},
}
for _, testCase := range testCases {
result := BuildLogFormatUpstream(testCase.useProxyProtocol)
if result != testCase.expected {
t.Errorf(" expected %v but return %v", testCase.expected, result)
}
}
}