diff --git a/CHANGELOG.md b/CHANGELOG.md index 073eaad1..b711fb75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - Updated the hooks watcher to account for the case when hooksDir is a symlink ([#5789](https://github.com/pocketbase/pocketbase/issues/5789)). +- _(Backported from v0.23.0-rc)_ Registered a default `http.Server.ErrorLog` handler to report general server connection errors as app Debug level logs (e.g. invalid TLS handshakes caused by bots trying to access your server via its IP or other similar errors). + - Other minor fixes (updated npm dev deps to fix the vulnerabilities warning, added more user friendly realtime topic length error, regenerated JSVM types, etc.) diff --git a/apis/serve.go b/apis/serve.go index 1984c131..90f4628b 100644 --- a/apis/serve.go +++ b/apis/serve.go @@ -159,6 +159,7 @@ func Serve(app core.App, config ServeConfig) (*http.Server, error) { BaseContext: func(l net.Listener) context.Context { return baseCtx }, + ErrorLog: log.New(&serverErrorLogWriter{app: app}, "", 0), } serveEvent := &core.ServeEvent{ @@ -275,3 +276,13 @@ func runMigrations(app core.App) error { return nil } + +type serverErrorLogWriter struct { + app core.App +} + +func (s *serverErrorLogWriter) Write(p []byte) (int, error) { + s.app.Logger().Debug(strings.TrimSpace(string(p))) + + return len(p), nil +}