logFromEvent example

/** * Subscribes to a statement execution finished event. * * Logs the statement query if logging is active. * * @param \Drupal\Core\Database\Event\StatementExecutionEndEvent $event * The database event. */
  public function onStatementExecutionEnd(StatementExecutionEndEvent $event): void {
    $logger = Database::getConnection($event->target, $event->key)->getLogger();
    if ($logger) {
      $logger->logFromEvent($event);
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.