本文整理汇总了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.');
}