[PR #868] [MERGED] Added the NoopHandler. #1388

Closed
opened 2026-03-04 03:11:40 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Seldaek/monolog/pull/868
Author: @ComaVN
Created: 10/12/2016
Status: Merged
Merged: 11/13/2016
Merged by: @Seldaek

Base: masterHead: noop-handler


📝 Commits (2)

  • 7284f7d Added the NoopHandler.
  • c370308 removed unused data provider in test

📊 Changes

3 files changed (+93 additions, -0 deletions)

View changed files

📝 doc/02-handlers-formatters-processors.md (+2 -0)
src/Monolog/Handler/NoopHandler.php (+42 -0)
tests/Monolog/Handler/NoopHandlerTest.php (+49 -0)

📄 Description

This handler handles anything, but does nothing, and does not stop bubbling to the rest of the stack, unlike the NullHandler.

This can be used for testing, or to disable a handler when overriding a configuration without influencing the rest of the stack.

The specific use-case I need this for is in symfony, where config_test.yml imports config_dev.yml, but needs to disable some handlers and add some others:

config_dev.yml:

monolog:
    handlers:
        stderr:
            type:   stream
            path:   "php://stderr"
            level:  debug

config_test.yml:

imports:
    - { resource: config_dev.yml }
monolog:
    handlers:
        test:
            type:   test
            level:  debug
        stderr:
            type:   'null'

This fails, because the stderr handler is first in the stack, even after overriding it. Because the NullHandler doesn't bubble, the test handler is never called. This would be solved with type: 'noop'


🔄 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/868 **Author:** [@ComaVN](https://github.com/ComaVN) **Created:** 10/12/2016 **Status:** ✅ Merged **Merged:** 11/13/2016 **Merged by:** [@Seldaek](https://github.com/Seldaek) **Base:** `master` ← **Head:** `noop-handler` --- ### 📝 Commits (2) - [`7284f7d`](https://github.com/Seldaek/monolog/commit/7284f7d9dc25970f27896743536e8138b142b978) Added the NoopHandler. - [`c370308`](https://github.com/Seldaek/monolog/commit/c3703081396b98df483f69da552370d3d6e12931) removed unused data provider in test ### 📊 Changes **3 files changed** (+93 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `doc/02-handlers-formatters-processors.md` (+2 -0) ➕ `src/Monolog/Handler/NoopHandler.php` (+42 -0) ➕ `tests/Monolog/Handler/NoopHandlerTest.php` (+49 -0) </details> ### 📄 Description This handler handles anything, but does nothing, and does not stop bubbling to the rest of the stack, unlike the NullHandler. This can be used for testing, or to disable a handler when overriding a configuration without influencing the rest of the stack. The specific use-case I need this for is in symfony, where `config_test.yml` imports `config_dev.yml`, but needs to disable some handlers and add some others: `config_dev.yml`: ``` monolog: handlers: stderr: type: stream path: "php://stderr" level: debug ``` `config_test.yml`: ``` imports: - { resource: config_dev.yml } monolog: handlers: test: type: test level: debug stderr: type: 'null' ``` This fails, because the `stderr` handler is first in the stack, even after overriding it. Because the NullHandler doesn't bubble, the `test` handler is never called. This would be solved with `type: 'noop'` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 03:11:40 +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#1388
No description provided.