Files
Jeremy Mikola cf125e32b1 PHPC-2180: Allow applications to register a log message subscriber (#1395)
* Introduce LogSubscriber interface and integrate with Monitoring API

LogSubscribers can be registered globally with existing add/removeSubscriber functions, and can be used as an alternative to the mongodb.debug INI setting with the notable difference that MONGOC_LOG_LEVEL_TRACE messages will not be dispatched to LogSubscribers (too verbose).

An internal mongoc_log() function is introduced purely testing in both PHPC and PHPLIB. It will not be documented and should not be used by applications.

* Use call_user_function instead of zend_call_method_if_exists

zend_call_method_if_exists() was introduced in PHP 8.2, so this ensures compatibility back to PHP 7.4.

This could still be optimized to initialize FCI/FCC structs when a logger is first registered. If so, call_user_function can be replaced with zend_call_function().

* Rely on contravariance to simplify interface implementations in tests  

These methods are never called, so type hints are unnecessary

* Test add/removeSubscriber behavior with LogSubscriber&CommandSubscriber

* PHPC-2289: Prohibit passing LogSubscriber to Manager::addSubscriber()

libmongoc does not yet support client-level logging, so only allow LogSubscribers to be registered globally.
2023-09-21 12:22:45 -04:00
..