1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2024-11-24 09:02:26 +02:00

registered a default http.Server.ErrorLog handler

This commit is contained in:
Gani Georgiev 2024-11-03 12:25:54 +02:00
parent 08793ee99f
commit 26ef0c697c
2 changed files with 13 additions and 0 deletions

View File

@ -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)). - 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.) - Other minor fixes (updated npm dev deps to fix the vulnerabilities warning, added more user friendly realtime topic length error, regenerated JSVM types, etc.)

View File

@ -159,6 +159,7 @@ func Serve(app core.App, config ServeConfig) (*http.Server, error) {
BaseContext: func(l net.Listener) context.Context { BaseContext: func(l net.Listener) context.Context {
return baseCtx return baseCtx
}, },
ErrorLog: log.New(&serverErrorLogWriter{app: app}, "", 0),
} }
serveEvent := &core.ServeEvent{ serveEvent := &core.ServeEvent{
@ -275,3 +276,13 @@ func runMigrations(app core.App) error {
return nil 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
}