You are here

public function Log::log in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Database/Log.php \Drupal\Core\Database\Log::log()

Log a query to all active logging keys.

Parameters

\Drupal\Core\Database\StatementInterface $statement: The prepared statement object to log.

array $args: The arguments passed to the statement object.

float $time: The time the query took to execute as a float (in seconds with microsecond precision).

float $start: The time the query started as a float (in seconds since the Unix epoch with microsecond precision).

File

core/lib/Drupal/Core/Database/Log.php, line 117

Class

Log
Database query logger.

Namespace

Drupal\Core\Database

Code

public function log(StatementInterface $statement, $args, $time, float $start = NULL) {
  foreach (array_keys($this->queryLog) as $key) {

    // @todo Remove the method_exists check for getConnectionTarget in
    //   Drupal 10.
    // @see https://www.drupal.org/project/drupal/issues/3210310
    $this->queryLog[$key][] = [
      'query' => $statement
        ->getQueryString(),
      'args' => $args,
      'target' => method_exists($statement, 'getConnectionTarget') ? $statement
        ->getConnectionTarget() : $statement->dbh
        ->getTarget(),
      'caller' => $this
        ->findCaller(),
      'time' => $time,
      'start' => $start,
    ];
  }
}