Add log file close and reopen on receipt of SIGUSR1

This commit is contained in:
Richard Shepherd 2017-08-11 11:04:58 +01:00 committed by Ludovic Fernandez
parent 64b8fc52c3
commit 4e5fcac9cb
12 changed files with 343 additions and 25 deletions

View file

@ -78,14 +78,7 @@ func (s *AccessLogSuite) TestAccessLog(c *check.C) {
for i, line := range lines {
if len(line) > 0 {
count++
tokens, err := shellwords.Parse(line)
c.Assert(err, checker.IsNil)
c.Assert(tokens, checker.HasLen, 14)
c.Assert(tokens[6], checker.Matches, `^\d{3}$`)
c.Assert(tokens[10], checker.Equals, fmt.Sprintf("%d", i+1))
c.Assert(tokens[11], checker.HasPrefix, "frontend")
c.Assert(tokens[12], checker.HasPrefix, "http://127.0.0.1:808")
c.Assert(tokens[13], checker.Matches, `^\d+ms$`)
CheckAccessLogFormat(c, line, i)
}
}
c.Assert(count, checker.GreaterOrEqualThan, 3)
@ -99,6 +92,17 @@ func (s *AccessLogSuite) TestAccessLog(c *check.C) {
}
}
func CheckAccessLogFormat(c *check.C, line string, i int) {
tokens, err := shellwords.Parse(line)
c.Assert(err, checker.IsNil)
c.Assert(tokens, checker.HasLen, 14)
c.Assert(tokens[6], checker.Matches, `^\d{3}$`)
c.Assert(tokens[10], checker.Equals, fmt.Sprintf("%d", i+1))
c.Assert(tokens[11], checker.HasPrefix, "frontend")
c.Assert(tokens[12], checker.HasPrefix, "http://127.0.0.1:808")
c.Assert(tokens[13], checker.Matches, `^\d+ms$`)
}
func startAccessLogServer(port int) (ts *httptest.Server) {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Received query %s!\n", r.URL.Path[1:])