opensearch-project / opensearch-php

Official PHP Client for OpenSearch
Other
109 stars 58 forks source link

[BUG] Logging is not sufficient... The $context parameters is not properly used when logging to PSR\Log\LoggerInterface #158

Open jrglasgow opened 1 year ago

jrglasgow commented 1 year ago

What is the bug?

Logging is not sufficient... The $context parameters is not properly used when logging to PSR\Log\LoggerInterface

How can one reproduce the bug?

look at the logs that are produced

Request Success: from $this->log->info( 'Request Success:', array( 'method' => $request['http_method'], 'uri' => $uri, 'port' => $port, 'headers' => $request['headers'], 'HTTP code' => $response['status'], 'duration' => $response['transfer_stats']['total_time'], ) );

shyim commented 1 year ago

It looks okay. https://github.com/opensearch-project/opensearch-php/blob/8b6cdbce1c5c2436fa2458fc1c9f698d0fc760c7/src/OpenSearch/Connections/Connection.php#L396-L406

Which logger is in use?

jrglasgow commented 1 year ago

Using the Drupal LoggerChannelInterface and after reading the standards I see that what I was looking for was for opensearch-php to provide placeholders that would bring he context data into the message string. Drupal's LoggerChannelInterface doesn't automatically bring the context in unless there are placeholders in the message... this might be considered a failing in Drupal's implementation of the PSR\Log\LoggerInterface.

I will look into getting Drupal modified to add the context when displaying out outputting the logs along with the message.