Skip to content

feat: pass log context as structured data to handlers instead of appending message#10017

Open
michalsn wants to merge 1 commit intocodeigniter4:4.8from
michalsn:feat/logger-with-context
Open

feat: pass log context as structured data to handlers instead of appending message#10017
michalsn wants to merge 1 commit intocodeigniter4:4.8from
michalsn:feat/logger-with-context

Conversation

@michalsn
Copy link
Member

@michalsn michalsn commented Mar 2, 2026

Description
This PR passes the log context as structured data to handlers instead of appending it as a JSON string to the message inside the Logger.

HandlerInterface::handle() gains a third array $context = [] parameter carrying the full log context, with CI global context stored under HandlerInterface::GLOBAL_CONTEXT_KEY.

This allows handlers (such as ChromeHandler) to present the context as a structured object instead of a JSON-encoded string. Custom loggers can also take advantage of this to render context data natively (e.g., as expandable objects in browser dev tools or structured fields in external logging systems).

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn michalsn added enhancement PRs that improve existing functionalities breaking change Pull requests that may break existing functionalities 4.8 PRs that target the `4.8` branch. labels Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch. breaking change Pull requests that may break existing functionalities enhancement PRs that improve existing functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant