[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Log/Logger/ -> MessagequeueLogger.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Log\Logger;
  11  
  12  use Joomla\CMS\Factory;
  13  use Joomla\CMS\Log\Log;
  14  use Joomla\CMS\Log\LogEntry;
  15  use Joomla\CMS\Log\Logger;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('JPATH_PLATFORM') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Joomla MessageQueue logger class.
  23   *
  24   * This class is designed to output logs to a specific MySQL database table. Fields in this
  25   * table are based on the Syslog style of log output. This is designed to allow quick and
  26   * easy searching.
  27   *
  28   * @since  1.7.0
  29   */
  30  class MessagequeueLogger extends Logger
  31  {
  32      /**
  33       * Method to add an entry to the log.
  34       *
  35       * @param   LogEntry  $entry  The log entry object to add to the log.
  36       *
  37       * @return  void
  38       *
  39       * @since   1.7.0
  40       */
  41      public function addEntry(LogEntry $entry)
  42      {
  43          switch ($entry->priority) {
  44              case Log::EMERGENCY:
  45              case Log::ALERT:
  46              case Log::CRITICAL:
  47              case Log::ERROR:
  48                  Factory::getApplication()->enqueueMessage($entry->message, 'error');
  49                  break;
  50              case Log::WARNING:
  51                  Factory::getApplication()->enqueueMessage($entry->message, 'warning');
  52                  break;
  53              case Log::NOTICE:
  54                  Factory::getApplication()->enqueueMessage($entry->message, 'notice');
  55                  break;
  56              case Log::INFO:
  57                  Factory::getApplication()->enqueueMessage($entry->message, 'message');
  58                  break;
  59              default:
  60                  // Ignore other priorities.
  61                  break;
  62          }
  63      }
  64  }


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