function Database::getLog

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::getLog()
  2. 8.9.x core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::getLog()
  3. 10 core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::getLog()
  4. 11.x core/lib/Drupal/Core/Database/Database.php \Drupal\Core\Database\Database::getLog()

Retrieves the queries logged on for given logging key.

This method also ends logging for the specified key. To get the query log to date without ending the logger request the logging object by starting it again (which does nothing to an open log key) and call methods on it as desired.

Parameters

$logging_key: The logging key to log.

$key: The database connection key for which we want to log.

Return value

array The query log for the specified logging key and connection.

See also

DatabaseLog

5 calls to Database::getLog()
DatabaseLoggingTestCase::testEnableLogging in modules/simpletest/tests/database_test.test
Test that we can log the existence of a query.
DatabaseLoggingTestCase::testEnableMultiConnectionLogging in modules/simpletest/tests/database_test.test
Test that we can log queries separately on different connections.
DatabaseLoggingTestCase::testEnableMultiLogging in modules/simpletest/tests/database_test.test
Test that we can run two logs in parallel.
DatabaseLoggingTestCase::testEnableTargetLogging in modules/simpletest/tests/database_test.test
Test that we can log queries against multiple targets on the same connection.
DatabaseLoggingTestCase::testEnableTargetLoggingNoTarget in modules/simpletest/tests/database_test.test
Test that logs to separate targets collapse to the same connection properly.

File

includes/database/database.inc, line 1546

Class

Database
Primary front-controller for the database system.

Code

public static final function getLog($logging_key, $key = 'default') {
    if (empty(self::$logs[$key])) {
        return NULL;
    }
    $queries = self::$logs[$key]->get($logging_key);
    self::$logs[$key]->end($logging_key);
    return $queries;
}

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