add rotatingloghandler which removes older log entries

This commit is contained in:
Florian Klink 2019-12-02 12:03:46 +01:00
parent 04a24a0c60
commit 118a88dace
4 changed files with 44 additions and 8 deletions

View file

@ -11,10 +11,9 @@ import (
"github.com/rakyll/statik/fs"
"github.com/tweag/gerrit-queue/gerrit"
"github.com/tweag/gerrit-queue/misc"
_ "github.com/tweag/gerrit-queue/statik" // register static assets
"github.com/tweag/gerrit-queue/submitqueue"
"github.com/apex/log/handlers/memory"
)
//loadTemplate loads a list of templates, relative to the statikFS root, and a FuncMap, and returns a template object
@ -48,7 +47,7 @@ func loadTemplate(templateNames []string, funcMap template.FuncMap) (*template.T
}
// MakeFrontend returns a http.Handler
func MakeFrontend(memoryHandler *memory.Handler, gerritClient *gerrit.Client, runner *submitqueue.Runner) http.Handler {
func MakeFrontend(rotatingLogHandler *misc.RotatingLogHandler, gerritClient *gerrit.Client, runner *submitqueue.Runner) http.Handler {
router := gin.Default()
projectName := gerritClient.GetProjectName()
@ -88,7 +87,7 @@ func MakeFrontend(memoryHandler *memory.Handler, gerritClient *gerrit.Client, ru
"HEAD": HEAD,
// History
"memory": memoryHandler,
"memory": rotatingLogHandler,
})
})
return router