当前位置: 首页>>代码示例>>PHP>>正文


PHP Kohana_Log::save方法代码示例

本文整理汇总了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;
 }
开发者ID:andyst,项目名称:gallery3,代码行数:37,代码来源:MY_Kohana_Exception.php

示例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);
     }
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:77,代码来源:Kohana_Exception.php


注:本文中的Kohana_Log::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。