Example #1
0
 protected function createExceptionHandlerLog(array $options)
 {
     $log = null;
     if (isset($options["class_name"]) && !empty($options["class_name"])) {
         if (isset($options["extension"]) && !empty($options["extension"]) && !extension_loaded($options["extension"])) {
             throw new Config\ConfigurationException(sprintf("Extension '%s' is not loaded for exception handler log", $options["extension"]));
         }
         if (isset($options["required_file"]) && !empty($options["required_file"]) && ($requiredFile = Loader::getLocal($options["required_file"])) !== false) {
             require_once $requiredFile;
         }
         $className = $options["class_name"];
         if (!class_exists($className)) {
             throw new Config\ConfigurationException(sprintf("Class '%s' does not exist for exception handler log", $className));
         }
         $log = new $className();
     } else {
         $log = new Diag\FileExceptionHandlerLog();
     }
     $log->initialize(isset($options["settings"]) && is_array($options["settings"]) ? $options["settings"] : array());
     return $log;
 }
Example #2
0
 public static function createExceptionHandlerLog()
 {
     $exceptionHandling = Config\Configuration::getValue("exception_handling");
     if ($exceptionHandling === null || !is_array($exceptionHandling) || !isset($exceptionHandling["log"]) || !is_array($exceptionHandling["log"])) {
         return null;
     }
     $options = $exceptionHandling["log"];
     $log = null;
     if (isset($options["class_name"]) && !empty($options["class_name"])) {
         if (isset($options["extension"]) && !empty($options["extension"]) && !extension_loaded($options["extension"])) {
             return null;
         }
         if (isset($options["required_file"]) && !empty($options["required_file"]) && ($requiredFile = Loader::getLocal($options["required_file"])) !== false) {
             require_once $requiredFile;
         }
         $className = $options["class_name"];
         if (!class_exists($className)) {
             return null;
         }
         $log = new $className();
     } elseif (isset($options["settings"]) && is_array($options["settings"])) {
         $log = new Diag\FileExceptionHandlerLog();
     } else {
         return null;
     }
     $log->initialize(isset($options["settings"]) && is_array($options["settings"]) ? $options["settings"] : array());
     return $log;
 }