Back to Log class

Method add

public static void
add
(mixed $entry, mixed $priority = self::INFO, mixed $category = '', mixed $date = null, array $context = array())
Method to add an entry to the log.
Parameters
  • mixed $entry The LogEntry object to add to the log or the message for a new LogEntry object.
  • int $priority Message priority.
  • string $category Type of entry
  • string $date Date of entry (defaults to now if not specified or blank)
  • array $context An optional array with additional message context.
Returns
  • void
Since
  • 1.7.0
Class: Log
Project: Joomla

Method add - Source code

/**
 * Method to add an entry to the log.
 *
 * @param   mixed    $entry     The LogEntry object to add to the log or the message for a new LogEntry object.
 * @param   integer  $priority  Message priority.
 * @param   string   $category  Type of entry
 * @param   string   $date      Date of entry (defaults to now if not specified or blank)
 * @param   array    $context   An optional array with additional message context.
 *
 * @return  void
 *
 * @since   1.7.0
 */
public static function add($entry, $priority = self::INFO, $category = '', $date = null, array $context = array())
{
    // Automatically instantiate the singleton object if not already done.
    if (empty(static::$instance)) {
        static::setInstance(new static());
    }
    // If the entry object isn't a LogEntry object let's make one.
    if (!$entry instanceof LogEntry) {
        $entry = new LogEntry((string) $entry, $priority, $category, $date, $context);
    }
    static::$instance->addLogEntry($entry);
}