algoliasearch-client-python icon indicating copy to clipboard operation
algoliasearch-client-python copied to clipboard

Missing logger

Open nunomaduro opened this issue 6 years ago • 0 comments
trafficstars

  • Algolia Client Version: latest

Description

On the Algolia PHP Client, there is the logger feature that allow us to log what happens when a search|or other method is called. By default, there is a debug logger that will print the requests that are made by the client:

Algolia\AlgoliaSearch\Logger\DebugLogger::enable();

$index->search('foo'); // Dumps information about the request on the console.

Algolia\AlgoliaSearch\Logger\DebugLogger::disable();

Example output on the console:

array:3 [
  "level" => "debug"
  "message" => "Algolia API client: Sending request."
  "context" => array:6 [
    "body" => array:1 [
      "query" => "fo"
    ]
    "headers" => array:4 [
      "X-Algolia-Application-Id" => ".."
      "X-Algolia-API-Key" => ".."
      "User-Agent" => "Algolia for PHP (2.2.6); PHP (7.3.5)"
      "Content-Type" => "application/json"
    ]
    "method" => "POST"
    "query" => []
    "retryNumber" => 1
    "host" => "https://..-dsn.algolia.net/1/indexes/contacts/query"
  ]
]
array:3 [
  "level" => "debug"
  "message" => "Algolia API client: Host failed."
  "context" => array:7 [
    "body" => array:1 [
      "query" => "fo"
    ]
    "headers" => array:4 [
      "X-Algolia-Application-Id" => ".."
      "X-Algolia-API-Key" => ".."
      "User-Agent" => "Algolia for PHP (2.2.6); PHP (7.3.5)"
      "Content-Type" => "application/json"
    ]
    "method" => "POST"
    "query" => []
    "retryNumber" => 1
    "host" => "https://..-dsn.algolia.net/1/indexes/contacts/query"
    "description" => "An internal server error occurred on ..-dsn.algolia.net"
  ]
]

This issue addresses that feature, as we don't have a logger on the python client. The idea, would be inject a concrete implementation of the logger on the client, allowing people to use this logger for debug purposes, but also, eventually for production reasons using their own specific logger.

nunomaduro avatar Jun 24 '19 15:06 nunomaduro