[ 
https://issues.apache.org/jira/browse/THRIFT-6009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Volodymyr Panivko resolved THRIFT-6009.
---------------------------------------
    Resolution: Fixed

> Add PSR-3 logger support and runtime deprecation warnings to PHP transports
> ---------------------------------------------------------------------------
>
>                 Key: THRIFT-6009
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6009
>             Project: Thrift
>          Issue Type: Improvement
>          Components: PHP - Library
>            Reporter: Volodymyr Panivko
>            Assignee: Volodymyr Panivko
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> h3. Problem
> The PHP socket transports ({{TSocket}}, {{TSSLSocket}}, {{TSocketPool}}) 
> accepted a {{$debugHandler}} typed {{callable|string|null}}, defaulting to 
> {{'error_log'}}, invoked via {{call_user_func()}}. There was no way to wire 
> in a {{Psr\Log\LoggerInterface}} directly. Additionally, 
> {{TSSLServerSocket::getSSLHost()}} was marked {{@deprecated}} in its docblock 
> but emitted no runtime warning.
> h3. What was done
> * Added {{psr/log: ^1.0 || ^2.0 || ^3.0}} to {{composer.json}}. Thrift is a 
> consumer of the interface, so the multi-major constraint is safe.
> * Widened {{$debugHandler}} on the three transports to 
> {{LoggerInterface|callable|string|null}}.
> * Introduced a single {{protected log(string $level, string $message)}} 
> helper on {{TSocket}} that routes diagnostics:
> ** {{LoggerInterface}} — always invoked; the logger filters by level. 
> Per-call-site mapping in {{TSocketPool::open()}}: {{DEBUG}} for 
> retry-interval-elapsed, {{WARNING}} for marking host down, {{ERROR}} for 
> connection failures and all-hosts-down.
> ** legacy callable / string — gated by {{setDebug()}} for BC; constructor 
> emits {{E_USER_DEPRECATED}}.
> ** no handler + {{setDebug(true)}} — falls back to {{error_log()}}, 
> preserving master's stderr output.
> * {{setDebug()}} retained (gates the legacy path) but marked {{@deprecated}} 
> and emits {{E_USER_DEPRECATED}}. No effect on the PSR-3 path.
> * {{TSSLServerSocket::getSSLHost()}} now emits {{E_USER_DEPRECATED}} at 
> runtime.
> * {{test/php/TestClient.php}} demonstrates the new API by injecting a small 
> PSR-3 {{StderrLogger}}.
> * Shared {{Test\Thrift\Unit\Lib\UserDeprecationCapture}} test trait factors 
> out the {{E_USER_DEPRECATED}} capture pattern.
> h3. Backwards compatibility
> All three common runtime cases preserve master behaviour:
> * no handler + no {{setDebug}} → silent (as before)
> * no handler + {{setDebug(true)}} → writes via {{error_log()}} (as before)
> * legacy callable / string + {{setDebug(true)}} → callable invoked (as 
> before; with deprecation warning)
> h3. PR
> https://github.com/apache/thrift/pull/3490



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to