refactor(log): return int from HandlerInterface::handle() - #10578
Open
Alexandros-Pallis wants to merge 1 commit into
Open
Alexandros-Pallis wants to merge 1 commit into
Alexandros-Pallis wants to merge 1 commit into
Conversation
Returning false stopped the handler chain, and built-in handlers returned false on write failure. A failing FileHandler (e.g. bad permissions) silently blocked later handlers such as ErrorlogHandler. handle() now returns RESULT_CONTINUE or RESULT_STOP. Built-in handlers always return RESULT_CONTINUE, so a write failure no longer stops the chain. Logger only stops on RESULT_STOP. BREAKING CHANGE: custom log handlers must change the handle() return type from bool to int and return HandlerInterface::RESULT_CONTINUE (was true) or RESULT_STOP (was false). A handler still declaring `: bool` is a fatal error at class load. See upgrade_480.rst.
neznaika0
reviewed
Sep 21, 2026
neznaika0
left a comment
Contributor
There was a problem hiding this comment.
It looks logical, but now we practically have no option to stop the handler - result is always returned to continue processing.
Perhaps, after these changes, stopping is not required at all, in which case, what’s the point of the new constants?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #10560 , implementing the approach agreed there for
4.8.Problem
Logger::log()stops running handlers when one returnsfalsefromhandle(). The built-in handlers (FileHandler,ErrorlogHandler) returnfalsewhen a write fails, so one failing handler (e.g.FileHandlerwith bad permissions onthe log directory) silently prevents every handler after it from logging. A configured
ErrorlogHandlerfallback neverruns and the log entry is lost.
falsewas doing two jobs: "the write failed" and "stop the chain". A handler had no way to report one withouttriggering the other.
Change
HandlerInterface::handle()now returnsintinstead ofbool, as suggested by @paulbalandan:HandlerInterface::RESULT_CONTINUE(1): the remaining handlers run.HandlerInterface::RESULT_STOP(2): the chain stops.Logger::log()breaks only onRESULT_STOP. Any other value continues.The built-in handlers (
FileHandler,ErrorlogHandler,ChromeLoggerHandler) and the testTestHandleralways returnRESULT_CONTINUE, including when a write fails. That fixes the original problem.Behavior changes
FileHandlerthat cannot write no longer stops later handlers. Ondevelopit did.apart from the chain-stopping
break, but code callinghandle()directly and checking the result would no longer seefailures.
Breaking change
Custom log handlers that override
handle()must change the return type frombooltointand return the new constants (true->RESULT_CONTINUE,false->RESULT_STOP). A handler still declaring: boolis incompatible with the interface and causes a fatal error when the class loads. Migration steps are inupgrade_480.rst.Tests
LoggerTest: a handler returningRESULT_CONTINUElets the next handler run; one returningRESULT_STOPprevents it.FileHandlerTest: a file that cannot be opened returnsRESULT_CONTINUE.RESULT_CONTINUEinstead oftrue.tests/system/Logpasses (61 tests), also in random order.Docs
upgrade_480.rst: return type change, constants, before/after example.v4.8.0.rst: Interface Changes entry and a Changes entry for theFileHandlerbehavior.general/logging.rst: note on handler order and return values.Checklist
develop