THRIFT-6009: Add PSR-3 logger support and runtime deprecation warnings for PHP transports#3490
Open
sveneld wants to merge 1 commit into
Open
THRIFT-6009: Add PSR-3 logger support and runtime deprecation warnings for PHP transports#3490sveneld wants to merge 1 commit into
sveneld wants to merge 1 commit into
Conversation
Client: php * Require psr/log ^1 || ^2 || ^3. TSocket/TSSLSocket/TSocketPool constructors accept a Psr\Log\LoggerInterface as $debugHandler. The PSR-3 path is always invoked and the logger filters by level (per-call-site DEBUG / WARNING / ERROR in TSocketPool::open()). * Default with no handler is silent (NullLogger). When the caller enables setDebug(true) without supplying a handler, log() falls back to PHP error_log() — preserves master's stderr output. * Legacy callable / string $debugHandler is preserved for BC; constructor emits E_USER_DEPRECATED when used. setDebug() still gates that legacy path and is itself @deprecated. * TSSLServerSocket::getSSLHost() now emits E_USER_DEPRECATED. * TestClient.php demonstrates the new API via a small PSR-3 StderrLogger. * New Test\Thrift\Unit\Lib\UserDeprecationCapture trait factors shared E_USER_DEPRECATED capture out of the unit tests. Generated-by: Claude Opus 4.7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves THRIFT-6009.
The PHP socket transports (
TSocket,TSSLSocket,TSocketPool) previously accepted onlycallable|string|nullfor$debugHandler, defaulting to'error_log', invoked viacall_user_func(). There was no way to wire in a PSR-3 logger directly and the only@deprecatedAPI in the PHP library (TSSLServerSocket::getSSLHost()) emitted nothing at runtime.What this PR does
psr/log: ^1.0 || ^2.0 || ^3.0tocomposer.json. Thrift is a consumer ofLoggerInterface, so the multi-major constraint is safe.$debugHandleron the three transports toPsr\Log\LoggerInterface|callable|string|null.protected log(string $level, string $message)helper onTSocket:LoggerInterface— always invoked; the logger is responsible for level filtering. Per-call-siteLogLevelconstants are used:DEBUGfor the retry-interval-elapsed message,WARNINGfor marking a host down,ERRORfor connection failures and all-hosts-down.setDebug()for BC; constructor emitsE_USER_DEPRECATED.setDebug(true)— falls back to PHPerror_log(), preserving master's stderr output.setDebug()is kept (still gates the legacy callable path) but marked@deprecatedand emitsE_USER_DEPRECATED. It has no effect on the PSR-3 path.TSSLServerSocket::getSSLHost()now emitsE_USER_DEPRECATEDat runtime.test/php/TestClient.phpdemonstrates the new API by injecting a tinyStderrLogger extends AbstractLogger.Test coverage
TSocket,TSSLSocket,TSocketPool).$debugHandler.setDebug()deprecation regression guard.TSSLServerSocket::getSSLHost()runtime deprecation.Test\Thrift\Unit\Lib\UserDeprecationCapturetrait shared between tests.646 unit tests pass; PHPStan (level 6) clean;
phpcsclean;cross-test (java, go,rs,cpp,py,php,nodejs,nodets)passes.THRIFT-NNNN: …?[skip ci]— N/A.