本文整理汇总了PHP中Kohana_Log::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana_Log::save方法的具体用法?PHP Kohana_Log::save怎么用?PHP Kohana_Log::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kohana_Log
的用法示例。
在下文中一共展示了Kohana_Log::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _show_themed_error_page
/**
* Shows a themed error page.
* @see Kohana_Exception::handle
*/
private static function _show_themed_error_page(Exception $e)
{
// Create a text version of the exception
$error = Kohana_Exception::text($e);
// Add this exception to the log
Kohana_Log::add('error', $error);
// Manually save logs after exceptions
Kohana_Log::save();
if (!headers_sent()) {
if ($e instanceof Kohana_Exception) {
$e->sendHeaders();
} else {
header("HTTP/1.1 500 Internal Server Error");
}
}
$view = new Theme_View("page.html", "other", "error");
if ($e instanceof Kohana_404_Exception) {
$view->page_title = t("Dang... Page not found!");
$view->content = new View("error_404.html");
$user = identity::active_user();
$view->content->is_guest = $user && $user->guest;
if ($view->content->is_guest) {
$view->content->login_form = new View("login_ajax.html");
$view->content->login_form->form = auth::get_login_form("login/auth_html");
// Avoid anti-phishing protection by passing the url as session variable.
Session::instance()->set("continue_url", url::current(true));
}
} else {
$view->page_title = t("Dang... Something went wrong!");
$view->content = new View("error.html");
}
print $view;
}
示例2: handle
/**
* exception handler, displays the error message, source of the
* exception, and the stack trace of the error.
*
* @uses Kohana::message()
* @uses Kohana_Exception::text()
* @param object exception object
* @return void
*/
public static function handle(Exception $e)
{
try {
// Get the exception information
$type = get_class($e);
$code = $e->getCode();
$message = $e->getMessage();
// Create a text version of the exception
$error = Kohana_Exception::text($e);
// Add this exception to the log
Kohana_Log::add('error', $error);
// Manually save logs after exceptions
Kohana_Log::save();
if (Kohana::config('core.display_errors') === FALSE) {
// Do not show the details
$file = $line = NULL;
$trace = array();
$template = '_disabled';
} else {
$file = $e->getFile();
$line = $e->getLine();
$trace = $e->getTrace();
$template = '';
}
if ($e instanceof Kohana_Exception) {
$template = $e->getTemplate() . $template;
if (!headers_sent()) {
$e->sendHeaders();
}
// Use the human-readable error name
$code = Kohana::message('core.errors.' . $code);
} else {
$template = Kohana_Exception::$template . $template;
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if ($e instanceof ErrorException) {
// Use the human-readable error name
$code = Kohana::message('core.errors.' . $e->getSeverity());
if (version_compare(PHP_VERSION, '5.3', '<')) {
// Workaround for a bug in ErrorException::getTrace() that exists in
// all PHP 5.2 versions. @see http://bugs.php.net/45895
for ($i = count($trace) - 1; $i > 0; --$i) {
if (isset($trace[$i - 1]['args'])) {
// Re-position the arguments
$trace[$i]['args'] = $trace[$i - 1]['args'];
unset($trace[$i - 1]['args']);
}
}
}
}
}
// Clean the output buffer if one exists
ob_get_level() and ob_clean();
if ($template = Kohana::find_file('views', $template)) {
include $template;
}
} catch (Exception $e) {
// Clean the output buffer if one exists
ob_get_level() and ob_clean();
// Display the exception text
echo Kohana_Exception::text($e), "\n";
}
if (Kohana::$server_api === 'cli') {
// Exit with an error status
exit(1);
}
}