本文整理匯總了PHP中Drupal\Core\Database\Database::getLog方法的典型用法代碼示例。如果您正苦於以下問題:PHP Database::getLog方法的具體用法?PHP Database::getLog怎麽用?PHP Database::getLog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Database\Database
的用法示例。
在下文中一共展示了Database::getLog方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: endQueryCapture
/**
* Add the list of queries run during render to buildinfo.
*
* @see ViewUI::startQueryCapture()
*/
public function endQueryCapture()
{
$queries = Database::getLog('views');
$this->additionalQueries = $queries;
}
示例2: testEnableMultiConnectionLogging
/**
* Tests that we can log queries separately on different connections.
*/
function testEnableMultiConnectionLogging()
{
// Clone the primary credentials to a fake connection.
// That both connections point to the same physical database is irrelevant.
$connection_info = Database::getConnectionInfo('default');
Database::addConnectionInfo('test2', 'default', $connection_info['default']);
Database::startLog('testing1');
Database::startLog('testing1', 'test2');
db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol();
$old_key = db_set_active('test2');
db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'), array('target' => 'replica'))->fetchCol();
db_set_active($old_key);
$queries1 = Database::getLog('testing1');
$queries2 = Database::getLog('testing1', 'test2');
$this->assertEqual(count($queries1), 1, 'Correct number of queries recorded for first connection.');
$this->assertEqual(count($queries2), 1, 'Correct number of queries recorded for second connection.');
}
示例3: getLog
public static final function getLog($logging_key, $key = 'default')
{
return BaseDatabase::getLog($logging_key, $key);
}
示例4: logResponse
/**
* Log the termination of a request.
*
* @param Response $response
* @param Request $request
*/
protected function logResponse(Response $response, Request $request)
{
$queries = Database::getLog('console_logger', 'default');
$sum = 0;
if (!empty($queries)) {
foreach ($queries as $query) {
$text[] = $query['query'];
$sum += $query['time'];
}
$querySummary = 'Executed {queries} queries in {time_ms} ms.';
$this->logger->log($this->logLevel, $querySummary, ['queries' => count($queries), 'time_ms' => round($sum * 1000, 2)]);
}
if ($response->headers->has('x-debug-token-link')) {
$this->logger->log($this->logLevel, 'Profiler at {url}', ['url' => $GLOBALS['base_url'] . $response->headers->get('x-debug-token-link')]);
}
}
示例5: testGetLoggingWrongKey
/**
* Tests that getLog with a wrong key return an empty array.
*/
function testGetLoggingWrongKey()
{
$result = Database::getLog('wrong');
$this->assertEqual($result, [], 'The function getLog with a wrong key returns an empty array.');
}