Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Database.php

function Database::startLog

Starts logging a given logging key on the specified connection.

Parameters

string $logging_key: The logging key to log.

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

Return value

\Drupal\Core\Database\Log The query log object. Note that the log object does support richer methods than the few exposed through the Database class, so in some cases it may be desirable to access it directly.

See also

\Drupal\Core\Database\Log

1 call to Database::startLog()
ViewUI::startQueryCapture in core/modules/views_ui/src/ViewUI.php
Set up query capturing.

File

core/lib/Drupal/Core/Database/Database.php, line 76

Class

Database
Primary front-controller for the database system.

Namespace

Drupal\Core\Database

Code

public static final function startLog($logging_key, $key = 'default') {
    if (empty(self::$logs[$key])) {
        self::$logs[$key] = new Log($key);
        // Every target already active for this connection key needs to have the
        // logging object associated with it.
        if (!empty(self::$connections[$key])) {
            foreach (self::$connections[$key] as $connection) {
                $connection->enableEvents(StatementEvent::all());
                $connection->setLogger(self::$logs[$key]);
            }
        }
    }
    self::$logs[$key]->start($logging_key);
    return self::$logs[$key];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal