function Log::log

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Database/Log.php \Drupal\Core\Database\Log::log()
  2. 10 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,
        ];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.