Skip to content

Comments

ref(logs): implement __destruct to make sure logs are always flushed#1916

Merged
Litarnus merged 3 commits intomasterfrom
martinl/logs-handler-destructor
Sep 22, 2025
Merged

ref(logs): implement __destruct to make sure logs are always flushed#1916
Litarnus merged 3 commits intomasterfrom
martinl/logs-handler-destructor

Conversation

@Litarnus
Copy link
Contributor

@Litarnus Litarnus commented Sep 18, 2025

This PR updates the LogsHandler to extent \Monolog\Handler\Handler so that we inherit the __destruct method which will flush when being destructed.

Implements __destruct manually to make sure that logs are always flushed once the handler is destructed.
This will make sure that no logs are lost in case calling flush() is forgotten.

We cannot use \Monolog\Handler\Handler because it is not available for the lowest version of monolog we support.

resolves #1915
closes PHP-33

@Litarnus Litarnus linked an issue Sep 18, 2025 that may be closed by this pull request
@linear
Copy link

linear bot commented Sep 18, 2025

@Litarnus Litarnus changed the title ref(logs): extend abstract Handler instead of implementing HandlerInterface ref(logs): implement __destruct to make sure logs are always flushed Sep 18, 2025
@Litarnus Litarnus requested a review from stayallive September 18, 2025 16:19
@Litarnus Litarnus marked this pull request as ready for review September 18, 2025 16:19
@Litarnus Litarnus self-assigned this Sep 18, 2025
@Litarnus Litarnus merged commit e26db2e into master Sep 22, 2025
39 checks passed
@Litarnus Litarnus deleted the martinl/logs-handler-destructor branch September 22, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LogsHandler should call close() on __desctuct().

2 participants