RequestLogger.php in Search API Elasticsearch 8
File
src/Logger/RequestLogger.php
View source
<?php
namespace Drupal\search_api_elasticsearch\Logger;
use Drupal\Core\Logger\RfcLoggerTrait;
use Psr\Log\LoggerInterface;
class RequestLogger implements LoggerInterface {
use RfcLoggerTrait;
public function __construct(LoggerInterface $logger = null, $debug = false) {
$this->logger = $logger;
$this->debug = $debug;
}
public function logQuery($path, $method, $data, $connection = array(), $query = array()) {
if ($this->debug) {
$this->queries[] = array(
'path' => $path,
'method' => $method,
'data' => $data,
'connection' => $connection,
'queryString' => $query,
);
}
if ($this->logger !== null) {
$message = sprintf("%s (%s)", $path, $method);
$this->logger
->info($message, (array) $data);
}
}
public function log($level, $message, array $context = array()) {
return $this->logger
->log($level, $message, $context);
}
}
Classes
Name |
Description |
RequestLogger |
Class QueryLogger
@package Drupal\search_api_elasticsearch\Logger |