Back to Log class

Method findLoggers

protected array
findLoggers
(mixed $priority, mixed $category)
Method to find the loggers to use based on priority and category values.
Parameters
  • int $priority Message priority.
  • string $category Type of entry
Returns
  • array The array of loggers to use for the given priority and category values.
Since
  • 1.7.0
Class: Log
Project: Joomla

Method findLoggers - Source code

/**
 * Method to find the loggers to use based on priority and category values.
 *
 * @param   integer  $priority  Message priority.
 * @param   string   $category  Type of entry
 *
 * @return  array  The array of loggers to use for the given priority and category values.
 *
 * @since   1.7.0
 */
protected function findLoggers($priority, $category)
{
    $loggers = array();
    // Sanitize inputs.
    $priority = (int) $priority;
    $category = strtolower((string) $category);
    // Let's go iterate over the loggers and get all the ones we need.
    foreach ((array) $this->lookup as $signature => $rules) {
        // Check to make sure the priority matches the logger.
        if ($priority & $rules->priorities) {
            if ($rules->exclude) {
                // If either there are no set categories or the category (including the empty case) is not in the list of excluded categories, add this logger.
                if (empty($rules->categories) || !\in_array($category, $rules->categories)) {
                    $loggers[] = $signature;
                }
            } else {
                // If either there are no set categories (meaning all) or the specific category is set, add this logger.
                if (empty($rules->categories) || \in_array($category, $rules->categories)) {
                    $loggers[] = $signature;
                }
            }
        }
    }
    return $loggers;
}