Example #1
0
 /**
  * Constructor
  *
  * @param   SHAdapter  $adapter   Adapter for log.
  * @param   string     $message   The message to log.
  * @param   integer    $id        Internal ID code of entry.
  * @param   string     $priority  Message priority based on {$this->priorities}.
  * @param   string     $category  Type of entry.
  * @param   string     $date      Date of entry (defaults to now if not specified or blank).
  *
  * @since   2.1
  */
 public function __construct(SHAdapter $adapter, $message, $id, $priority = JLog::INFO, $category = null, $date = null)
 {
     // Get the adapter type and transform it to human readable
     $type = $adapter::TYPE;
     if ($type === SHAdapter::TYPE_USER) {
         $this->adapterType = 'User';
         $this->adapterId = $adapter->loginUser;
     } elseif ($type === SHAdapter::TYPE_GROUP) {
         $this->adapterType = 'Group';
         //$this->adapterId = $adapter->getId();
     } else {
         $this->adapterType = 'Generic';
         $this->adapterId = 'N/A';
     }
     // Domain of the adapter user/group
     $this->adapterDomain = $adapter->getDomain();
     if (empty($category)) {
         $category = strtolower($adapter->getName());
     }
     parent::__construct($id, $message, $priority, $category, $date);
     // Creates a one liner for everything
     $this->full = JText::sprintf('(%1$s::%2$s::%3$s) %4$s', $this->adapterType, $this->adapterDomain, $this->adapterId, $this->message);
 }
Example #2
0
 /**
  * Constructor
  *
  * @param   Exception  $exception  The PHP Exception.
  * @param   integer    $id         Optional ID of the error (not the exception error).
  * @param   string     $priority   Message priority based on {$this->priorities}.
  * @param   string     $category   Type of entry
  * @param   string     $date       Date of entry (defaults to now if not specified or blank)
  *
  * @since   2.0
  */
 public function __construct(Exception $exception, $id = 0, $priority = JLog::INFO, $category = '', $date = null)
 {
     // Uses the exceptions toString for the exceptions string
     $this->full = (string) $exception;
     // Internal Error ID of the exception
     $this->code = $exception->getCode();
     // Replace the ID if it is empty
     if ($id === 0) {
         $id = $this->code;
     }
     // Uses the translated internal Error ID message
     $message = $exception->getMessage();
     // Trace
     $this->trace = $exception->getTraceAsString();
     // File occurred
     $this->file = $exception->getFile();
     // Line occurred
     $this->line = $exception->getLine();
     parent::__construct($id, $message, $priority, $category, $date);
 }