Source for file entry.php

Documentation is available at entry.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Log
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Joomla! Log Entry class
  14.  *
  15.  * This class is designed to hold log entries for either writing to an engine, or for
  16.  * supported engines, retrieving lists and building in memory (PHP based) search operations.
  17.  *
  18.  * @package     Joomla.Platform
  19.  * @subpackage  Log
  20.  * @since       11.1
  21.  */
  22. class JLogEntry
  23. {
  24.     /**
  25.      * Application responsible for log entry.
  26.      * @var    string 
  27.      * @since  11.1
  28.      */
  29.     public $category;
  30.  
  31.     /**
  32.      * The date the message was logged.
  33.      * @var    JDate 
  34.      * @since  11.1
  35.      */
  36.     public $date;
  37.  
  38.     /**
  39.      * Message to be logged.
  40.      * @var    string 
  41.      * @since  11.1
  42.      */
  43.     public $message;
  44.  
  45.     /**
  46.      * The priority of the message to be logged.
  47.      * @var    string 
  48.      * @since  11.1
  49.      * @see    JLogEntry::$priorities
  50.      */
  51.     public $priority = JLog::INFO;
  52.  
  53.     /**
  54.      * List of available log priority levels [Based on the Syslog default levels].
  55.      * @var    array 
  56.      * @since  11.1
  57.      */
  58.     protected $priorities = array(
  59.         JLog::EMERGENCY,
  60.         JLog::ALERT,
  61.         JLog::CRITICAL,
  62.         JLog::ERROR,
  63.         JLog::WARNING,
  64.         JLog::NOTICE,
  65.         JLog::INFO,
  66.         JLog::DEBUG
  67.     );
  68.  
  69.     /**
  70.      * Constructor
  71.      *
  72.      * @param   string  $message   The message to log.
  73.      * @param   string  $priority  Message priority based on {$this->priorities}.
  74.      * @param   string  $category  Type of entry
  75.      * @param   string  $date      Date of entry (defaults to now if not specified or blank)
  76.      *
  77.      * @since   11.1
  78.      */
  79.     public function __construct($message$priority JLog::INFO$category ''$date null)
  80.     {
  81.         $this->message = (string) $message;
  82.  
  83.         // Sanitize the priority.
  84.         if (!in_array($priority$this->prioritiestrue))
  85.         {
  86.             $priority JLog::INFO;
  87.         }
  88.         $this->priority = $priority;
  89.  
  90.         // Sanitize category if it exists.
  91.         if (!empty($category))
  92.         {
  93.             $this->category = (string) strtolower(preg_replace('/[^A-Z0-9_\.-]/i'''$category));
  94.         }
  95.  
  96.         // Get the date as a JDate object.
  97.         $this->date = new JDate($date $date 'now');
  98.     }
  99. }

Documentation generated on Tue, 19 Nov 2013 15:02:30 +0100 by phpDocumentor 1.4.3