Readable traffic log: drop heartbeat noise, surface visitors and errors
Deploy with Docker Compose / deploy (push) Successful in 50s
Deploy with Docker Compose / deploy (push) Successful in 50s
Replaces gin's default logger with a custom formatter: - /auth/validate-admin (nginx auth_request subrequests — the 5-seconds flood that is not a user), /auth/refresh and /auth/check no longer log a line at all on success; their failures are kept. - Human latency units (15ms, not 153020ns). - Lines for requests from outside the docker subnet carry the client IP — the "who is using my site" line — while internal infrastructure successes stay lean. - 4xx lines carry " !!", 5xx " !!! SERVER ERROR", both greppable. The admin panel's Diagnostics log pane gains a "visitors only" filter that keeps just the IP-suffixed and error lines (on by default). Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
+6
-1
@@ -43,7 +43,12 @@ func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
r := gin.Default()
|
||||
r := gin.New()
|
||||
// Custom traffic formatter (services/traffic_log.go) instead of gin's
|
||||
// default: quiets heartbeat subrequests, surfaces external visitors and
|
||||
// server errors. Same writer pair as above.
|
||||
r.Use(gin.LoggerWithFormatter(services.TrafficLogFormatter))
|
||||
r.Use(gin.Recovery())
|
||||
|
||||
// Only the Docker network nginx sits on may set X-Forwarded-For. Without
|
||||
// this pin any client could spoof its IP and defeat the per-IP login rate
|
||||
|
||||
Reference in New Issue
Block a user