コード例 #1
0
ファイル: _globals.php プロジェクト: noccy80/cherryphp
function debug($fmt, $args = null)
{
    $args = func_get_args();
    array_unshift($args, LOG_DEBUG);
    if (DEBUG_VERBOSE) {
        $bt = debug_backtrace();
        if (count($bt) > 1) {
            $ol = \Cherry\Core\Debug::getLineInfo($bt[1]);
            if ($ol) {
                $args[1] = $ol . ' ' . $args[1];
            }
        }
    }
    call_user_func_array(array('\\Cherry\\Core\\DebugLog', 'log'), $args);
}
コード例 #2
0
ファイル: autoloader.php プロジェクト: noccy80/cherryphp
 /**
  *
  *
  */
 public function autoload($class)
 {
     //$this->debug("Autoload requested: {$class}");
     if ($this->ns) {
         $cm = strtolower($class);
         $nm = strtolower($this->ns);
         if (substr($cm, 0, strlen($nm)) == $nm) {
             $cf = substr($class, strlen($nm));
         } else {
             return false;
         }
     } else {
         $cf = $class;
     }
     if (strpos($cf, '_') !== false) {
         $cfn = str_replace('_', _DS_, $cf);
     } else {
         $cfn = str_replace("\\", '/', $cf);
     }
     $loc = $this->path . _DS_;
     $extn = (array) explode("|", $this->options['extensions']);
     $tested = [];
     if ($this->options['casepreserve'] == self::CP_LOWERCASE) {
         foreach ($extn as $ext) {
             $fl = $loc . strtolower($cfn) . $ext;
             $tested[] = $fl;
             if (file_exists($fl) && is_readable($fl)) {
                 require_once $fl;
                 $this->debugInfo($fl, $class);
                 return true;
             }
         }
     } elseif ($this->options['casepreserve'] == self::CP_PRESEVE) {
         foreach ($extn as $ext) {
             $fl = $loc . $cfn . $ext;
             $tested[] = $fl;
             if (file_exists($fl) && is_readable($fl)) {
                 require_once $fl;
                 $this->debugInfo($fl, $class);
                 return true;
             }
         }
     } else {
         for ($case = 0; $case < 2; $case++) {
             foreach ($extn as $ext) {
                 $fl = $loc . ($case == 1 ? strtolower($cfn) : $cfn) . $ext;
                 $tested[] = $fl;
                 if (file_exists($fl) && is_readable($fl)) {
                     require_once $fl;
                     $this->debugInfo($fl, $class);
                     return true;
                 }
             }
         }
     }
     $bt = \Cherry\Core\Debug::getCaller(3);
     $srcfile = empty($bt["file"]) ? "na" : $bt["file"];
     $srcline = empty($bt["line"]) ? "na" : $bt["line"];
     $this->debug("No candidate for autoloading {$class}; tried %s [from %s]", join(", ", $tested), "{$srcfile}:{$srcline}");
     return false;
 }
コード例 #3
0
 public function handleException(\Exception $exception)
 {
     $this->debug("Unhandled exception %s in %s on line %d", get_class($exception), $exception->getFile(), $exception->getLine());
     $log = DebugLog::getDebugLog();
     $ca = \Cherry\Cli\Console::getAdapter();
     $fbt = $exception->getTrace();
     if (defined("ERROR_POPBACK")) {
         $errfile = $fbt[2]['file'];
         $errline = $fbt[2]['line'];
         array_shift($fbt);
     } else {
         $errfile = $exception->getFile();
         $errline = $exception->getLine();
     }
     $bt = \Cherry\Core\Debug::makeBacktrace($fbt, true);
     $this->showError($ca, 'Exception', $exception->getMessage() . ' (' . $exception->getCode() . ')', $errfile, $errline, $log, $bt);
     exit(1);
 }