/** * @param Throwable $exception */ public static function logException($exception) { $type = Ajde_Exception_Handler::getTypeDescription($exception); $level = Ajde_Exception_Handler::getExceptionLevelMap($exception); $channel = Ajde_Exception_Handler::getExceptionChannelMap($exception); $trace = strip_tags(Ajde_Exception_Handler::trace($exception, Ajde_Exception_Handler::EXCEPTION_TRACE_ONLY)); Ajde_Log::_($exception->getMessage(), $channel, $level, $type, sprintf('%s on line %s', $exception->getFile(), $exception->getLine()), $trace); }
public function __toString() { try { $output = $this->output(); } catch (Exception $e) { $output = Ajde_Exception_Handler::handler($e); } return (string) $output; }
function shutdown() { if (($error = error_get_last()) && in_array($error['type'], array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR))) { $exception = new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']); if (Config::get('debug') === true) { echo Ajde_Exception_Handler::trace($exception); } else { // Use native PHP error log function, as Ajde_Exception_Log does not work error_log($error['message'] . ', ' . $error['type'] . ', ' . $error['file'] . ', ' . $error['line']); Ajde_Http_Response::dieOnCode(Ajde_Http_Response::RESPONSE_TYPE_SERVERERROR); } } }
protected static function embedScript($filename = null, $line = null, $arguments = null, $expand = false) { $lineOffset = 5; $file = ''; if (isset($filename) && isset($line)) { $lines = file($filename); for ($i = max(0, $line - $lineOffset - 1); $i < min($line + $lineOffset, count($lines)); $i++) { $lineNumber = str_repeat(" ", 4 - strlen($i + 1)) . ($i + 1); if ($i == $line - 1) { $file .= "{{{}}}" . $lineNumber . ' ' . $lines[$i] . "{{{/}}}"; } else { $file .= $lineNumber . ' ' . $lines[$i]; } } } if (substr_count($filename, str_replace('/', DIRECTORY_SEPARATOR, APP_DIR))) { $filename = '<span style="color: red;">' . $filename . '</span>'; if (self::$firstApplicationFileExpanded === false) { $expand = true; } self::$firstApplicationFileExpanded = true; } $file = highlight_string("<?php" . $file, true); $file = str_replace('<?php', '', $file); $file = str_replace('<code>', "<code style='display:block;border:1px solid silver;margin:5px 0 5px 0;background-color:#f1f1f1;'>", $file); $file = str_replace('{{{}}}', "<div style='background-color: #ffff9e;'>", $file); $file = str_replace('{{{/}}}', "</div>", $file); $id = md5(microtime()); return sprintf("<a\n\t\t\t\t\tonclick='document.getElementById(\"{$id}\").style.display = document.getElementById(\"{$id}\").style.display == \"block\" ? \"none\" : \"block\";'\n\t\t\t\t\thref='javascript:void(0);'\n\t\t\t\t><i>%s</i> on line <b>%s</b></a> <div id='{$id}' style='display:%s;'>%s%s</div>", $filename, $line, $expand ? "block" : "none", $file, $arguments); }
public static function logException(Exception $exception) { $trace = strip_tags(Ajde_Exception_Handler::trace($exception, Ajde_Exception_Handler::EXCEPTION_TRACE_LOG)); Ajde_Log::log($trace); }
public function process() { return Ajde_Exception_Handler::handler($this); }
public function log($ident, $module) { Ajde_Log::_('Language key [' . $module . '.' . $ident . '] not found for language [' . Ajde_Lang::getInstance()->getLang() . ']', Ajde_Log::CHANNEL_INFO, Ajde_Log::LEVEL_DEBUG, '', '', strip_tags(Ajde_Exception_Handler::trace(new Ajde_Exception(), Ajde_Exception_Handler::EXCEPTION_TRACE_ONLY))); }