Back to FormattedtextLogger class

Method addEntry

public void
addEntry
(\Joomla\CMS\Log\LogEntry $entry)
Method to add an entry to the log.
Parameters
  • \Joomla\CMS\Log\LogEntry $entry The log entry object to add to the log.
Returns
  • void
Since
  • 1.7.0
-
  • \RuntimeException

Method addEntry - Source code

/**
 * Method to add an entry to the log.
 *
 * @param   LogEntry  $entry  The log entry object to add to the log.
 *
 * @return  void
 *
 * @since   1.7.0
 * @throws  \RuntimeException
 */
public function addEntry(LogEntry $entry)
{
    // Store the entry to be written later.
    if ($this->defer) {
        $this->deferredEntries[] = $entry;
    } else {
        // Initialise the file if not already done.
        $this->initFile();
        // Write the new entry to the file.
        $line = $this->formatLine($entry);
        $line .= "\n";
        if (!File::append($this->path, $line)) {
            throw new \RuntimeException('Cannot write to log file.');
        }
    }
}