Add FrankenPhpHandler - #2056
Open
dunglas wants to merge 3 commits into
Open
Conversation
Logs records using FrankenPHP's frankenphp_log() function, mapping Monolog's levels onto slog's level scale, with an e2e test running against a real FrankenPHP server.
Assert level and message come from the same structured log line instead of independent substring checks, since the record's own raw level int lands in the same JSON object as zap's level string. Also mount the fixture app read-only.
write() was passing Monolog's own raw int "level" through to frankenphp_log(), landing in the same JSON object as slog's own "level" severity string under the same key - PHPUnit's json_decode() silently keeps only the last one, so any consumer decoding this JSON (including a naive test) would read the wrong field. Drop it (level_name already carries the same info) and assert on decoded JSON instead of regex now that the field is unambiguous.
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.
Adds a handler for FrankenPHP's
frankenphp_log(), which writes structured logs through FrankenPHP's Golog/slog-based logger instead oferror_log().function_exists('frankenphp_log')in the constructor, throwingMissingExtensionExceptionoutside FrankenPHP (same pattern asZendMonitorHandler).FRANKENPHP_LOG_LEVEL_*constants for Debug/Info/Warning/Error, and custom ints for Notice/Critical/Alert/Emergency following slog's documented gap-of-4 convention for intermediate levels (see the docblock onFrankenPhpHandler::toFrankenPhpLevel()).FrankenPhpHandlerE2ETest(tagged#[Group('e2e')]) makes real HTTP calls to a FrankenPHP server and inspects its structured log output, skipping itself if no server is reachable. CI runs it againstdunglas/frankenphp:latestvia aservices:container in.github/workflows/frankenphp-e2e.yml.