sveneld opened a new pull request, #3490:
URL: https://github.com/apache/thrift/pull/3490

   <!-- Explain the changes in the pull request below: -->
   
   Resolves [THRIFT-6009](https://issues.apache.org/jira/browse/THRIFT-6009).
   
   The three PHP socket transports (`TSocket`, `TSSLSocket`, `TSocketPool`) 
accepted a `$debugHandler` typed `callable|string|null`, defaulting to 
`'error_log'` (a legacy string-callable). They could not accept a PSR-3 logger 
directly, and the only `@deprecated` API in the PHP library 
(`TSSLServerSocket::getSSLHost()`) emitted no runtime warning.
   
   **This PR:**
   - Adds `psr/log: ^1.0 || ^2.0 || ^3.0` to `composer.json`. Thrift is a 
consumer of `LoggerInterface`, so the multi-major constraint is safe.
   - Widens `$debugHandler` to `Psr\Log\LoggerInterface|callable|string|null` 
on all three transports.
   - Introduces a single protected `log(string $level, string $message)` helper 
on `TSocket` that dispatches to either a legacy callable or the PSR-3 logger.
   - Maps call sites to per-message log levels: `DEBUG` for 
retry-interval-elapsed, `WARNING` for marking-host-down, `ERROR` for connection 
failures and all-hosts-down.
   - Emits `E_USER_DEPRECATED` via `trigger_error()` when a string is passed 
for `$debugHandler` (legacy function-name form). Closure / invokable / Logger 
instances are unchanged.
   - Emits `E_USER_DEPRECATED` from `TSSLServerSocket::getSSLHost()`.
   - Marks `TSocket::DEFAULT_DEBUG_HANDLER` `@deprecated`.
   
   **Behavior change worth noting:** previously, `setDebug(true)` with no 
explicit handler routed messages to PHP's `error_log`. After this change the 
default is `NullLogger` (silent). Users wanting the old behavior pass a 
`LoggerInterface` (e.g. `Monolog` writing to syslog) or a closure `fn($m) => 
error_log($m)`. The library is pre-1.0, so this change is permitted under the 
project's compatibility policy.
   
   Test coverage added for:
   - LoggerInterface dispatch with per-call-site levels (TSocket, TSSLSocket, 
TSocketPool)
   - String-handler deprecation trigger (TSocket, TSSLSocket)
   - Null-handler / closure silence guard (TSocket)
   - `getSSLHost()` runtime deprecation (TSSLServerSocket)
   
   All 645 unit tests pass; PHPStan (level 6) clean; `phpcs 
--standard=phpcs.xml.dist` clean.
   
   - [x] Did you create an [Apache 
Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket? — 
THRIFT-6009
   - [x] If a ticket exists: Does your pull request title follow the pattern 
"THRIFT-NNNN: describe my issue"?
   - [x] Did you squash your changes to a single commit?
   - [x] Did you do your best to avoid breaking changes? — One intentional 
behavior change documented above (NullLogger default). Pre-1.0 release; not 
labeled Breaking-Change.
   - [ ] If your change does not involve any code, include `[skip ci]` anywhere 
in the commit message to free up build resources. — N/A, code changes included.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to