log and health check

This commit is contained in:
Marco Pedone 2026-05-26 12:36:52 +02:00
parent 97079fd3fa
commit 43568aeb36
2 changed files with 23 additions and 2 deletions

View file

@ -22,8 +22,29 @@ func main() {
u = NewUpdater()
e := echo.New()
e.Use(middleware.RequestLogger())
skipper := func(c *echo.Context) bool {
// Skip health check endpoint
return c.Request().URL.Path == "/health"
}
e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
LogStatus: true,
LogURI: true,
LogMethod: true,
Skipper: skipper,
HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
LogValuesFunc: func(c *echo.Context, v middleware.RequestLoggerValues) error {
var errMsg string
if v.Error != nil {
errMsg = fmt.Sprintf(" ERROR: %s", v.Error.Error())
}
fmt.Printf("[%s %s]: %d%s\n", v.Method, v.URI, v.Status, errMsg)
return nil
},
}))
e.GET("/", func(c *echo.Context) error {
return c.String(http.StatusOK, "OK")
})
e.GET("/test", func(c *echo.Context) error {
return c.JSONPretty(http.StatusOK,

View file

@ -81,7 +81,7 @@ services:
IMAGEOPTION: "true"
CONCURRENT_IMAGES: ${CONCURRENT_IMAGES}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:1323/health"]
test: ["CMD", "curl", "-f", "http://localhost:1323"]
interval: 10s
timeout: 5s
retries: 5