Elasticsuite: Doc: How to log CURL trace

Created on 13 Nov 2018  路  11Comments  路  Source: Smile-SA/elasticsuite

I saw the

\Elasticsearch\Connections\curlCommand

    // Build the curl command for Trace.
    $curlCommand = $this->buildCurlCommand($method, $fullURI, $body);
    $this->trace->info($curlCommand);

I am wondering where this trace is written to? We should add it to the docs :)

question

All 11 comments

Hello @amenk

If you enable the Debug Mode as explained here : https://github.com/Smile-SA/elasticsuite/wiki/ModuleInstall#elasticsearch-client

The module will then produce logs through the Magento default logging system.

Regards

@romainruaud yes I was having debug mode on, but no trace with the CURL lines is created. The $this->trace is just a NullWriter

Hmm...

I'm actually seeing the Request Success in the Magento system log if I enable the debug mode, so it's actually working on my dev env.

@romainruaud
There is also $this->debug->info() around the above line. So it's supposed to log the request twice.
Once as debug, once as trace.

I am seeing the debug request as well.

The trace is an actual curl console command. So are you seeing a line that can be easily pasted to bash to replay the request?

If not, it's not working for you :-)

Whoops .. the code is actually inside the elasticsearch library:

vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:401

I did not see that ...

So it's more like, elasticsuite does not connect the trace log stream instead of "somebody implemented that in elasticsuite and did not document it".

Still would be interesting though how to get the curl commands logged, but not high priority.

Workaround is to set a breakpoint at that line and extract the curl command from the variable.

You are right, I'm only having this actually (on system.log) :

[2018-11-19 10:47:48] main.INFO: Request Success: {"method":"HEAD","uri":"http://10.0.3.35:9200/magento22ce_default_cms_page","headers":{"Host":["10.0.3.35:9200"],"Content-Type":["application/json"],"Accept":["application/json"]},"HTTP code":200,"duration":0.001946} []

So I think the $this->log->info() is fine, but yeah, $this->trace is not actually working.

Got it,

just adding $this->client->setTracer($this->logger) in Smile\ElasticsuiteCore\Client\ClientBuilder is enough to produce traces.

Cool, should we add that to the core module? Maybe making the log on/off setting a log level setting for off, debug, trace ?

For now, I think we can add it "as is" to the core module and schedule it for a release onto the next minor version.

Log level should be managed internally by Magento since we pass an implementation of LoggerInterface.

true, great :-)

Implemented in #1193

Was this page helpful?
0 / 5 - 0 ratings