Forward Log::withContext / Log::shareContext to FrankenPHP request-logs - #54
Open
LauJosefsen wants to merge 3 commits into
Open
Forward Log::withContext / Log::shareContext to FrankenPHP request-logs#54LauJosefsen wants to merge 3 commits into
LauJosefsen wants to merge 3 commits into
Conversation
Without clearing the facade's resolved-instance cache, Log::shareContext and Log::withContext can hit a stale LogManager that pre-dates our rebind, so context never reaches the request-logs extension.
The FrankenPHP request-logs extension uses frankenphp.GoMap to convert the PHP array to Go primitives, which silently drops the entire call when it hits a PHP object (UuidInterface, Carbon, etc.). Round-trip through json_encode/decode so objects flatten to their JSON scalar representation and survive the conversion. The original array is untouched, so parent::shareContext() / Monolog handlers still receive the objects unchanged.
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.
Summary
ForwardingLogManagerthat extendsIlluminate\Log\LogManagerand forwards context attached viaLog::withContext()andLog::shareContext()into the FrankenPHPrequest-logsextension (\Cego\RequestLogs\context()).FilebeatLoggingServiceProvider::register()rebinds thelogsingleton to the forwarding manager.Context
Companion to cego/frankenphp-image!264, which adds a Go-side per-request context store and the PHP function
\Cego\RequestLogs\context(). This package is the idiomatic Laravel bridge: application code callsLog::withContext(['user' => ['id' => $id]])from middleware, and the fields appear on both the Monolog app-log records AND the final access-log line emitted by the Caddyrequest-logsmiddleware.Not forwarded
Log::channel('x')->withContext([...])— per-channel scoping does not map cleanly to a cross-cutting request log entry. Documented in the README section.