示例#1
0
文件: Json.php 项目: imjerrybao/phpbu
 /**
  * Set the log configuration.
  *
  * @param  \phpbu\App\Configuration $configuration
  * @throws \phpbu\App\Exception
  */
 public function setLoggers(Configuration $configuration)
 {
     if (isset($this->json['logging'])) {
         foreach ($this->json['logging'] as $l) {
             if (!isset($l['type'])) {
                 throw new Exception('invalid logger configuration: type missing');
             }
             $type = $l['type'];
             $options = $this->getOptions($l);
             if (isset($options['target'])) {
                 $options['target'] = $this->toAbsolutePath($options['target']);
             }
             // search for target attribute to convert to option
             if (isset($l['target'])) {
                 $options['target'] = $this->toAbsolutePath($l['target']);
             }
             $configuration->addLogger(new Configuration\Logger($type, $options));
         }
     }
 }
示例#2
0
 /**
  * Set the log configuration.
  *
  * @param  \phpbu\App\Configuration $configuration
  * @throws \phpbu\App\Exception
  */
 public function setLoggers(Configuration $configuration)
 {
     /** @var \DOMElement $logNode */
     foreach ($this->xpath->query('logging/log') as $logNode) {
         $type = $logNode->getAttribute('type');
         if (!$type) {
             throw new Exception('invalid logger configuration: attribute type missing');
         }
         $options = $this->getOptions($logNode);
         if (isset($options['target'])) {
             $options['target'] = $this->toAbsolutePath($options['target']);
         }
         // search for target attribute to convert to option
         $target = $logNode->getAttribute('target');
         if (!empty($target)) {
             $options['target'] = $this->toAbsolutePath($target);
         }
         $configuration->addLogger(new Configuration\Logger($type, $options));
     }
 }