/** * @see \Components\Debug_Appender::append() append */ public function append($severity_, array $args_, $style_ = Debug::STYLE_PLAIN, $sourceFile_ = null, $sourceLine_ = null) { echo '<pre style="text-align:left;background:white;color:black;">'; foreach ($args_ as $arg) { if ($arg instanceof \Exception) { exception_print_html($arg, true, true); } else { print_r($arg); } } echo '</pre>'; }
/** * @link http://php.net/manual/en/function.register-shutdown-function.php */ public function onExit() { $error = error_get_last(); if (null !== $error) { $this->onError($error['type'], $error['message'], $error['file'], $error['line']); } if (self::$m_isCli) { $hasErrors = 0 < count(self::$m_exceptions); foreach (self::$m_exceptions as $exception) { exception_print_cli($exception, true, true); } if (false === @is_file(self::$m_cacheFile)) { Cache::dump(self::$m_cacheFile); } exit(false === $hasErrors ? 0 : -1); } if (Debug::active() && (self::isManagementAccess() || Environment::isDev())) { if (0 < count(self::$m_exceptions)) { Debug::verror(self::$m_exceptions); } Debug::flush(); self::$m_exceptions = []; } if (false === Environment::isDev()) { self::$m_exceptions = []; } foreach (self::$m_exceptions as $exception) { exception_print_html($exception, true, true); } }
/** * Render & print HTML formatted details for given exception. * * @param \Exception $e_ * @param bool $includeSource_ * @param bool $includeStackTrace_ */ function exception_print_html(\Exception $e_, $includeSource_ = false, $includeStackTrace_ = false) { if ($includeSource_) { $type = Components\Type::of($e_); printf(' <h1 style="color:black;background:white;font:17px/20px mono;text-align:left;margin:0;padding:0;">[%1$s] %2$s</h1> <h2 style="color:black;background:white;font:15px/17px mono;text-align:left;margin:0;padding:0;">%3$s</h2> <h3 style="color:black;background:white;font:13px/15px mono;text-align:left;margin:0;padding:0;">%4$s</h3> <pre style="color:black;background:white;font:11px/13px mono;text-align:left;margin:0;padding:0;">%5$s</pre>', \math\hasho_md5($e_), $type->name(), $e_->getMessage(), $includeSource_ ? implode(':', [$e_->getFile(), $e_->getLine()]) : '', $includeStackTrace_ ? $e_->getTraceAsString() : ''); } else { printf('<h1>%1$s</h1><h2>%2$s</h2>', \math\hasho_md5($e_), $e_->getMessage()); if ($includeStackTrace_) { echo '<pre>' . $e_->getTraceAsString() . '</pre>'; } } if ($cause = $e_->getPrevious()) { exception_print_html($cause, $includeSource_, $includeStackTrace_); } }