[PR #641] [CLOSED] Added the capability of handling a message multiple times #1273

Closed
opened 2026-03-04 03:08:07 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Seldaek/monolog/pull/641
Author: @mjacobus
Created: 9/7/2015
Status: Closed

Base: masterHead: feature/multiple-handles-for-same-message


📝 Commits (1)

  • a353c2b Added the capability of handling a message multiple times

📊 Changes

2 files changed (+45 additions, -3 deletions)

View changed files

📝 src/Monolog/Logger.php (+5 -3)
📝 tests/Monolog/LoggerTest.php (+40 -0)

📄 Description

What if I want error messages to be logged, but critical messages to be logged, mailed and sent to slack channel?

If I understood correctly this is currently not possible. This is why I created this PR, to add such capability.

$log = new Logger('name');
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::ERROR));
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::CRITICAL));
$log->pushHandler(new MyEmailHandler(Logger::CRITICAL));
$log->pushHandler(new SlackHandler($connectionString, Logger::CRITICAL));

Note that 2 tests are now failing. I did not change them because I was not sure if that was testing the expected behavior or if it was just very strict expectations, since the commit that introduced those tests seemed just to be increasing the test coverage.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Seldaek/monolog/pull/641 **Author:** [@mjacobus](https://github.com/mjacobus) **Created:** 9/7/2015 **Status:** ❌ Closed **Base:** `master` ← **Head:** `feature/multiple-handles-for-same-message` --- ### 📝 Commits (1) - [`a353c2b`](https://github.com/Seldaek/monolog/commit/a353c2be61c112ee4077e0774acd284ada1597f5) Added the capability of handling a message multiple times ### 📊 Changes **2 files changed** (+45 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/Monolog/Logger.php` (+5 -3) 📝 `tests/Monolog/LoggerTest.php` (+40 -0) </details> ### 📄 Description What if I want error messages to be logged, but critical messages to be logged, mailed and sent to slack channel? If I understood correctly this is currently not possible. This is why I created this PR, to add such capability. ``` php $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger::ERROR)); $log->pushHandler(new StreamHandler('path/to/your.log', Logger::CRITICAL)); $log->pushHandler(new MyEmailHandler(Logger::CRITICAL)); $log->pushHandler(new SlackHandler($connectionString, Logger::CRITICAL)); ``` Note that 2 tests are now failing. I did not change them because I was not sure if that was testing the expected behavior or if it was just very strict expectations, since the [commit](https://github.com/Seldaek/monolog/commit/64009a58) that introduced those tests seemed just to be increasing the test coverage. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 03:08:07 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#1273
No description provided.