Skip to content

feat: add UidProcessor to all Monolog channels and route newrelic via dedicated driver#3

Draft
Copilot wants to merge 2 commits into
masterfrom
copilot/improve-logger-best-practices
Draft

feat: add UidProcessor to all Monolog channels and route newrelic via dedicated driver#3
Copilot wants to merge 2 commits into
masterfrom
copilot/improve-logger-best-practices

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 9, 2026

Modernizes the logger by attaching a unique request UID to every log record and ensuring New Relic receives log data through the correct driver path.

Changes

  • src/Manager/HasProcessors.php — new trait exposing processors() returning [new UidProcessor()]; designed to be overridden per-app if needed
  • src/Manager.php — composes HasProcessors alongside existing traits
  • src/Manager/CreateDrivers.php — passes $this->processors() to new Monolog(...) in createStackDriver, createSingleDriver, createDailyDriver, and createEmergencyLogger
  • src/Manager/MonologWrappers.php — passes $this->processors() in createMonologDriver (covers all monolog-driver channels)
  • config/logging.php — fixes newrelic channel: was driver: monolog pointing at a non-existent \Nip\Logger\Monolog\Handler\NewRelicHandler; now uses driver: newrelic, which routes through createNewrelicDriver()\ByTIC\NewRelic\Monolog\Handler

Result

Every channel (file, New Relic, custom monolog) now tags records with a shared UID:

// Each log record's `extra` array will contain:
['uid' => 'a3f2c1b']  // same value across all channels for the same request

This makes cross-channel correlation (e.g. matching a file log entry to its New Relic counterpart) trivial.

Copilot AI and others added 2 commits May 9, 2026 07:58
…r config

Agent-Logs-Url: https://github.com/bytic/logger/sessions/15d9cf7a-05ba-410f-83d6-31ff0a9cb9cb

Co-authored-by: gabrielsolomon <17990591+gabrielsolomon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/bytic/logger/sessions/15d9cf7a-05ba-410f-83d6-31ff0a9cb9cb

Co-authored-by: gabrielsolomon <17990591+gabrielsolomon@users.noreply.github.com>
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.

2 participants