[PR #50] [CLOSED] Functions to disable temporarily the logging. #903

Closed
opened 2026-03-04 03:02:33 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Seldaek/monolog/pull/50
Author: @rafacouto
Created: 12/29/2011
Status: Closed

Base: masterHead: patch-1


📝 Commits (2)

  • 2f38f21 Functions to disable temporally the logging
  • 7cf4432 Patch for the patch (sorry, it was edited in the air via github): Now, $enabled is private field of class (not static).

📊 Changes

1 file changed (+29 additions, -0 deletions)

View changed files

📝 src/Monolog/Logger.php (+29 -0)

📄 Description

    /**
     * @return boolean Returns true when logging is currently enabled.
     */
    public function isEnabled()

    /**
     * @param boolean $enable Enable (true) or disable (false) the logging.
     */
    public function setEnabled($enable)

It might be useful within controled loops when a suboperation makes logging and you could not deactivate it. For example:

// logger as a symfony container
$this->Logger = $this->getContainer()->get('logger');

// ...

// a very intensive controlled loop
while ($quantity-- > 0) {
    $this->Logger->setEnabled(false);
    $this->LabelRepository->createLabel($serial);
    $this->Logger->setEnabled(true);
}

🔄 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/50 **Author:** [@rafacouto](https://github.com/rafacouto) **Created:** 12/29/2011 **Status:** ❌ Closed **Base:** `master` ← **Head:** `patch-1` --- ### 📝 Commits (2) - [`2f38f21`](https://github.com/Seldaek/monolog/commit/2f38f21f5ff14f2cff06e5416ecb57031e903a06) Functions to disable temporally the logging - [`7cf4432`](https://github.com/Seldaek/monolog/commit/7cf4432b717452be87b727bfc2c9265fcb3611e3) Patch for the patch (sorry, it was edited in the air via github): Now, $enabled is private field of class (not static). ### 📊 Changes **1 file changed** (+29 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/Monolog/Logger.php` (+29 -0) </details> ### 📄 Description ``` php /** * @return boolean Returns true when logging is currently enabled. */ public function isEnabled() /** * @param boolean $enable Enable (true) or disable (false) the logging. */ public function setEnabled($enable) ``` It might be useful within controled loops when a suboperation makes logging and you could not deactivate it. For example: ``` php // logger as a symfony container $this->Logger = $this->getContainer()->get('logger'); // ... // a very intensive controlled loop while ($quantity-- > 0) { $this->Logger->setEnabled(false); $this->LabelRepository->createLabel($serial); $this->Logger->setEnabled(true); } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 03:02:33 +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#903
No description provided.