Back to FormattedtextLogger class

Method __construct

public
__construct
(array &$options)
Constructor.
Parameters
  • array & $options Log object options.
Since
  • 1.7.0

Method __construct - Source code

/**
 * Constructor.
 *
 * @param   array  &$options  Log object options.
 *
 * @since   1.7.0
 */
public function __construct(array &$options)
{
    // Call the parent constructor.
    parent::__construct($options);
    // The name of the text file defaults to 'error.php' if not explicitly given.
    if (empty($this->options['text_file'])) {
        $this->options['text_file'] = 'error.php';
    }
    // The name of the text file path defaults to that which is set in configuration if not explicitly given.
    if (empty($this->options['text_file_path'])) {
        $this->options['text_file_path'] = Factory::getApplication()->get('log_path', JPATH_ADMINISTRATOR . '/logs');
    }
    // False to treat the log file as a php file.
    if (empty($this->options['text_file_no_php'])) {
        $this->options['text_file_no_php'] = false;
    }
    // Build the full path to the log file.
    $this->path = $this->options['text_file_path'] . '/' . $this->options['text_file'];
    // Use the default entry format unless explicitly set otherwise.
    if (!empty($this->options['text_entry_format'])) {
        $this->format = (string) $this->options['text_entry_format'];
    }
    // Wait as long as possible before writing logs
    if (!empty($this->options['defer'])) {
        $this->defer = (bool) $this->options['defer'];
    }
    // Build the fields array based on the format string.
    $this->parseFields();
}