laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.73k stars 289 forks source link

[2.x] Closes monolog handlers by event listener if the worker stops #854

Closed NiroDeveloper closed 4 months ago

NiroDeveloper commented 4 months ago

Fix for #850 Laravel uses Monolog for logging, some monolog handler have a important close() function. Octane does never call this function! In normal laravel applications, monolog calls close by itself via destruct(). It seams like destruct() is never called in Swoole, so close the handler manually per event.

taylorotwell commented 4 months ago

Drafting until @nunomaduro can review.

taylorotwell commented 4 months ago

@NiroDeveloper how did you decide it should be placed on WorkerStopping? Why not OperationTerminated?

NiroDeveloper commented 4 months ago

The handler should be reused for every request / operation, so it should just call close() at the end of the worker process. There is already a FlushMonologState listener that calls reset() on the handler between every request, this is the correct behavior as descripted by monolog.

taylorotwell commented 4 months ago

Thanks @NiroDeveloper