[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2011 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\Log\LogEntry;
  13  use Joomla\CMS\Log\Logger;
  14  
  15  // phpcs:disable PSR1.Files.SideEffects
  16  \defined('JPATH_PLATFORM') or die;
  17  // phpcs:enable PSR1.Files.SideEffects
  18  
  19  /**
  20   * Joomla Echo logger class.
  21   *
  22   * @since  1.7.0
  23   */
  24  class EchoLogger extends Logger
  25  {
  26      /**
  27       * Value to use at the end of an echoed log entry to separate lines.
  28       *
  29       * @var    string
  30       * @since  1.7.0
  31       */
  32      protected $line_separator = "\n";
  33  
  34      /**
  35       * Constructor.
  36       *
  37       * @param   array  &$options  Log object options.
  38       *
  39       * @since   3.0.0
  40       */
  41      public function __construct(array &$options)
  42      {
  43          parent::__construct($options);
  44  
  45          if (!empty($this->options['line_separator'])) {
  46              $this->line_separator = $this->options['line_separator'];
  47          }
  48      }
  49  
  50      /**
  51       * Method to add an entry to the log.
  52       *
  53       * @param   LogEntry  $entry  The log entry object to add to the log.
  54       *
  55       * @return  void
  56       *
  57       * @since   1.7.0
  58       */
  59      public function addEntry(LogEntry $entry)
  60      {
  61          echo $this->priorities[$entry->priority] . ': '
  62              . $entry->message . (empty($entry->category) ? '' : ' [' . $entry->category . ']')
  63              . $this->line_separator;
  64      }
  65  }


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