Пример #1
0
 /**
  * Store configuration
  * @param array $config
  */
 public function __construct(array $config)
 {
     $this->config = $config;
     if (!array_key_exists('mute', $config)) {
         $this->config['mute'] = false;
     }
     $this->formatter = new Bunyan();
     if (empty($config['filters'])) {
         $config['filters'] = array();
     }
     $this->filters = AbstractFilter::buildFilters($config['filters']);
     // If there are no processors, buildProcessors will return an empty SplObjectStorage
     if (empty($this->config['processors']) || !is_array($this->config['processors'])) {
         $this->config['processors'] = array();
     }
     $this->processors = $this->buildProcessors($this->config['processors']);
     if (array_key_exists('bubble', $this->config) && $this->config['bubble'] === false) {
         $this->bubble = false;
     }
     $this->init();
 }
Пример #2
0
 /**
  * Initialize with the app name and an options array
  * @param string $appName
  * @param array $options
  */
 public function __construct($appName, array $options)
 {
     if (empty($appName)) {
         throw new \InvalidArgumentException('Your logger instance must have a name');
     }
     $this->appName = $appName;
     $this->options = $options;
     $this->writers = new SplObjectStorage();
     if (!array_key_exists('filters', $this->options)) {
         $this->options['filters'] = array();
     }
     if (!array_key_exists('writers', $this->options)) {
         $this->options['writers'] = array();
     }
     if (!array_key_exists('mute', $this->options)) {
         $this->options['mute'] = false;
     }
     // We need a different exception handler to give some classes a special treatment
     if (!empty($this->options['exceptionHandler']) && is_callable($this->options['exceptionHandler'])) {
         $this->exceptionHandler = $this->options['exceptionHandler'];
     }
     $this->filters = AbstractFilter::buildFilters($this->options['filters']);
     $this->writers = $this->buildWriters($this->options['writers']);
 }
Пример #3
0
 /**
  * Include pseudo external filter
  */
 public function testBuildFiltersWithFilterNotImplementingIFilter()
 {
     $this->setExpectedException('\\RuntimeException');
     $config = array(array('\\stdClass' => array()));
     AbstractFilter::buildFilters($config);
 }