[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/joomla/database/src/Monitor/ -> LoggingMonitor.php (source)

   1  <?php
   2  /**
   3   * Part of the Joomla Framework Database Package
   4   *
   5   * @copyright  Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved.
   6   * @license    GNU General Public License version 2 or later; see LICENSE
   7   */
   8  
   9  namespace Joomla\Database\Monitor;
  10  
  11  use Joomla\Database\QueryMonitorInterface;
  12  use Psr\Log\LoggerAwareInterface;
  13  use Psr\Log\LoggerAwareTrait;
  14  
  15  /**
  16   * Query monitor handling logging of queries.
  17   *
  18   * @since  2.0.0
  19   */
  20  class LoggingMonitor implements QueryMonitorInterface, LoggerAwareInterface
  21  {
  22      use LoggerAwareTrait;
  23  
  24      /**
  25       * Act on a query being started.
  26       *
  27       * @param   string         $sql          The SQL to be executed.
  28       * @param   object[]|null  $boundParams  List of bound params, used with the query.
  29       *                                       Each item is an object that holds: value, dataType
  30       * @return  void
  31       *
  32       * @since   2.0.0
  33       */
  34  	public function startQuery(string $sql, ?array $boundParams = null): void
  35      {
  36          if ($this->logger)
  37          {
  38              // Add the query to the object queue.
  39              $this->logger->info(
  40                  'Query Executed: {sql}',
  41                  ['sql' => $sql, 'trace' => debug_backtrace()]
  42              );
  43          }
  44      }
  45  
  46      /**
  47       * Act on a query being stopped.
  48       *
  49       * @return  void
  50       *
  51       * @since   2.0.0
  52       */
  53  	public function stopQuery(): void
  54      {
  55          // Nothing to do
  56      }
  57  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer