예제 #1
0
파일: Echoo.php 프로젝트: kl07/log
 /**
  * Constructor.
  *
  * @param   array  &$options  Log object options.
  *
  * @since   1.0
  */
 public function __construct(array &$options)
 {
     parent::__construct($options);
     if (!empty($this->options['line_separator'])) {
         $this->line_separator = $this->options['line_separator'];
     }
 }
예제 #2
0
 /**
  * Constructor.
  *
  * @param   array  &$options  Log object options.
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 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'])) {
         throw new \RuntimeException(sprintf('%s requires a `text_file_path` option to be set.', __CLASS__));
     }
     // 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'];
     }
     // Build the fields array based on the format string.
     $this->parseFields();
 }
예제 #3
0
파일: Callback.php 프로젝트: kl07/log
 /**
  * Constructor.
  *
  * @param   array  &$options  Log object options.
  *
  * @since   1.0
  * @throws  \Exception
  */
 public function __construct(array &$options)
 {
     // Call the parent constructor.
     parent::__construct($options);
     // Throw an exception if there is not a valid callback
     if (isset($this->options['callback']) && is_callable($this->options['callback'])) {
         $this->callback = $this->options['callback'];
     } else {
         throw new \Exception(__CLASS__ . ' created without valid callback function.');
     }
 }
예제 #4
0
 /**
  * Constructor.
  *
  * @param   array  &$options  Log object options.
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function __construct(array &$options)
 {
     // Call the parent constructor.
     parent::__construct($options);
     // If we're missing the db object, or it's not an instance of DatabaseDriver, throw an exception.
     if (!isset($this->options['db']) || !$this->options['db'] instanceof DatabaseDriver) {
         throw new \RuntimeException(sprintf('%s requires a `db` option that is an instance of Joomla\\Database\\DatabaseDriver.', __CLASS__));
     }
     $this->db = $this->options['db'];
     // The table name is independent of how we arrived at the connection object.
     $this->table = empty($this->options['db_table']) ? '#__log_entries' : $this->options['db_table'];
 }
예제 #5
0
파일: Syslog.php 프로젝트: kl07/log
 /**
  * Constructor.
  *
  * @param   array  &$options  Log object options.
  *
  * @since   1.0
  */
 public function __construct(array &$options)
 {
     // Call the parent constructor.
     parent::__construct($options);
     // Ensure that we have an identity string for the Syslog entries.
     if (empty($this->options['sys_ident'])) {
         $this->options['sys_ident'] = 'Joomla Framework';
     }
     // If the option to add the process id to Syslog entries is set use it, otherwise default to true.
     if (isset($this->options['sys_add_pid'])) {
         $this->options['sys_add_pid'] = (bool) $this->options['sys_add_pid'];
     } else {
         $this->options['sys_add_pid'] = true;
     }
     // If the option to also send Syslog entries to STDERR is set use it, otherwise default to false.
     if (isset($this->options['sys_use_stderr'])) {
         $this->options['sys_use_stderr'] = (bool) $this->options['sys_use_stderr'];
     } else {
         $this->options['sys_use_stderr'] = false;
     }
     // Build the Syslog options from our log object options.
     $sysOptions = 0;
     if ($this->options['sys_add_pid']) {
         $sysOptions = $sysOptions | LOG_PID;
     }
     if ($this->options['sys_use_stderr']) {
         $sysOptions = $sysOptions | LOG_PERROR;
     }
     // Default logging facility is LOG_USER for Windows compatibility.
     $sysFacility = LOG_USER;
     // If we have a facility passed in and we're not on Windows, reset it.
     if (isset($this->options['sys_facility']) && !defined('PHP_WINDOWS_VERSION_MAJOR')) {
         $sysFacility = $this->options['sys_facility'];
     }
     // Open the Syslog connection.
     openlog((string) $this->options['sys_ident'], $sysOptions, $sysFacility);
 }