Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: recommend safer way to disable logging #11269

Merged
merged 2 commits into from
Feb 18, 2024

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Feb 18, 2024

Resetting the middlewares on the configuration object will only work if the connection object hasn't been built from that configuration object yet. Instead, people should find the logger bound to the logging middleware and disable it.

Note: I think that with Symfony, another solution might be to have this bundle configuration:

dbal:
    regular_connection:
        logging: true
    batch_connection:
        logging: false

Let me know what you think.

Comment on lines 25 to 26
For example, with Monolog, you can use ``Logger::popHandler()`` as
many times as necessary to remove all handlers from the logger.
Copy link
Member

@derrabus derrabus Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can push a NullHandler instead. The advantage of that approach is that you can pop the NullHandler after your heavy operation and the logger should start logging again.

Resetting the middlewares on the configuration object will only work if
the connection object hasn't been built from that configuration object
yet. Instead, people should find the logger bound to the logging
middleware and disable it.
@derrabus derrabus added this to the 2.18.1 milestone Feb 18, 2024
@derrabus derrabus merged commit e4769d3 into doctrine:2.18.x Feb 18, 2024
1 check passed
@greg0ire greg0ire deleted the fix-batch-processing-docs branch February 18, 2024 16:13
derrabus added a commit to derrabus/orm that referenced this pull request Feb 21, 2024
* 2.18.x:
  Fix Static Analysis folder reference (doctrine#11281)
  docs: recommend safer way to disable logging (doctrine#11269)
  Remove unused baseline entries
  Treat '0' as a legitimate trim char
derrabus added a commit to derrabus/orm that referenced this pull request Feb 21, 2024
* 2.18.x:
  Fix Static Analysis folder reference (doctrine#11281)
  docs: recommend safer way to disable logging (doctrine#11269)
  Remove unused baseline entries
  Treat '0' as a legitimate trim char
derrabus added a commit to derrabus/orm that referenced this pull request Feb 21, 2024
* 2.19.x:
  Fix Static Analysis folder reference (doctrine#11281)
  docs: recommend safer way to disable logging (doctrine#11269)
  Remove unused baseline entries
  Treat '0' as a legitimate trim char
  Add type field mapper documentation to the sidebar
  Mark document as orphan
  Use correction sectionauthor syntax
  Make docs valid according to guides 0.3.3 (doctrine#11252)
derrabus added a commit to derrabus/orm that referenced this pull request Feb 21, 2024
* 3.1.x:
  Fix Static Analysis folder reference (doctrine#11281)
  Remove broken assertion from DateAddFunction and DateSubFunction (doctrine#11243)
  Account for inversedBy being a non-falsy-string or null
  Improve static analysis on AttachEntityListenersListener
  docs: recommend safer way to disable logging (doctrine#11269)
  Remove unused baseline entries
  Treat '0' as a legitimate trim char
  Add type field mapper documentation to the sidebar
  Mark document as orphan
  Use correction sectionauthor syntax
  Remove unused trait
  [Documentation] Adding link to Postgres upgrade article (doctrine#11257)
  Validate more variadic parameters (doctrine#11261)
  Throw if a variadic parameter contains unexpected named arguments (doctrine#11260)
  Make docs valid according to guides 0.3.3 (doctrine#11252)
  fix: support array-type arg in QB variadic calls (doctrine#11242)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants