示例#1
0
文件: debug.php 项目: jonlb/JxCMS
 public static function dump($variable, $label = NULL, $type = 'log')
 {
     if (class_exists('Fire')) {
         switch ($type) {
             case 'info':
                 Fire::info($variable, $label);
                 break;
             case 'log':
                 Fire::log($variable, $label);
                 break;
             case 'warn':
                 Fire::warn($variable, $label);
                 break;
             case 'error':
                 Fire::error($variable, $label);
                 break;
             case 'dump':
                 Fire::dump($variable, $label);
                 break;
         }
     } else {
         if (isset($label)) {
             echo $label . ":";
         }
         echo "<br><pre>";
         var_dump($variable);
         echo "</pre><br>";
     }
 }
Kohana::$log->add('FirePHP::WARN', 'FirePHP Warn...');
Kohana::$log->add('FirePHP::ERROR', 'FirePHP Error...');
$demo = array('label' => 'FirePHP Table...', 'table' => array(array('Col 1 Heading', 'Col 2 Heading'), array('Row 1 Col 1', 'Row 1 Col 2'), array('Row 2 Col 1', 'Row 2 Col 2'), array('Row 3 Col 1', 'Row 3 Col 2')));
Kohana::$log->add('FirePHP::LOG', array('label' => 'Passing objects to log...', 'object' => $demo));
Kohana::$log->add('FirePHP::TABLE', $demo);
Kohana::$log->add('FirePHP::LOG', 'FirePHP Log...');
// Not sure what dump does... ???
Kohana::$log->add('FirePHP::DUMP', array('key' => 2, 'variable' => $demo));
Kohana::$log->add('FirePHP::TRACE', 'FirePHP Trace...');
Kohana::$log->add('FirePHP::GROUP_END', '')->write();
// However, its much easier to just do this...
// All FirePHP commands are available, plus a few new ones...
Fire::log('Hi Mom!');
Fire::group('My Group')->warn('Warning!')->groupEnd();
Fire::error('UH OH! Now, look what you did it!');
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'welcome', 'action' => 'index'));
/**
 * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
 * If no source is specified, the URI will be automatically detected.
 */
echo Request::instance()->execute()->send_headers()->response;
/**
 * Run the at the end of the bootstap to profile the entire application
 * Alternatively, you can extend one of the FirePHP Controllers
 */
Fire::warn('Be sure to configure FirePHP authorization for productions sites. Don\'t want just anybody viewing this stuff...');
FirePHP_Profiler::instance()->group('KO3 FirePHP Profiler Results:')->superglobals()->database()->benchmark()->groupEnd();
示例#3
0
 public function before()
 {
     parent::before();
     Fire::info($this->request, 'Before() called');
 }
示例#4
0
 public function add(Fire $fire)
 {
     $this->array[] = $fire->cloneMe();
 }
示例#5
0
文件: data.php 项目: ragchuck/ra-Log
 public function action_test()
 {
     $this->auto_render = FALSE;
     Fire::fb(ORM::factory('Data', 1));
 }
示例#6
0
 /**
  * Inline exception handler, displays the error message, source of the
  * exception, and the stack trace of the error.
  *
  * @uses Kohana_Exception::text
  * @param object exception object
  * @return boolean
  */
 public static function handler(Exception $e)
 {
     try {
         // Get the exception information
         $type = get_class($e);
         $code = $e->getCode();
         $message = $e->getMessage();
         $file = $e->getFile();
         $line = $e->getLine();
         // Get the exception backtrace
         $trace = $e->getTrace();
         if ($e instanceof ErrorException) {
             if (isset(Kohana_Exception::$php_errors[$code])) {
                 // Use the human-readable error name
                 $type = Kohana_Exception::$php_errors[$code];
             }
             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/bug.php?id=45895
                 for ($i = count($trace) - 1; $i > 0; --$i) {
                     if (isset($trace[$i - 1]['args'])) {
                         // Re-position the args
                         $trace[$i]['args'] = $trace[$i - 1]['args'];
                         // Remove the args
                         unset($trace[$i - 1]['args']);
                     }
                 }
             }
         }
         // Create a text version of the exception
         $error = Kohana_Exception::text($e);
         if (class_exists('Fire')) {
             Fire::fb($e);
         } elseif (is_object(Kohana::$log)) {
             // Add this exception to the log
             Kohana::$log->add(Log::ERROR, $error);
             $strace = Kohana_Exception::text($e) . "\n--\n" . $e->getTraceAsString();
             Kohana::$log->add(Log::STRACE, $strace);
             // Make sure the logs are written
             Kohana::$log->write();
         }
         if (Kohana::$is_cli) {
             // Just display the text of the exception
             echo "\n{$error}\n";
             exit(1);
         }
         if (Request::$current !== NULL and Request::current()->is_ajax() === TRUE) {
             $http_header_status = $e instanceof HTTP_Exception ? $code : 500;
             header('Content-Type: application/json; charset=' . Kohana::$charset, TRUE, $http_header_status);
             // Set up json object
             $data = array('error' => array('code' => $code, 'type' => $type, 'message' => $message, 'file' => $file, 'line' => $line, 'source' => self::source($file, $line)));
             $error = json_encode($data);
             // Just display the text of the exception
             echo "\n{$error}\n";
             exit(1);
         }
         if (!headers_sent()) {
             // Make sure the proper http header is sent
             $http_header_status = $e instanceof HTTP_Exception ? $code : 500;
             header('Content-Type: ' . Kohana_Exception::$error_view_content_type . '; charset=' . Kohana::$charset, TRUE, $http_header_status);
         }
         // Start an output buffer
         ob_start();
         // Include the exception HTML
         if ($view_file = Kohana::find_file('views', Kohana_Exception::$error_view)) {
             include $view_file;
         } else {
             throw new Kohana_Exception('Error view file does not exist: views/:file', array(':file' => Kohana_Exception::$error_view));
         }
         // Display the contents of the output buffer
         echo ob_get_clean();
         exit(1);
     } 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";
         // Exit with an error status
         exit(1);
     }
 }
示例#7
0
 public function parse_post(array $post)
 {
     Fire::info($post);
     $stream = array();
     foreach ($post as $name => $value) {
         if (strpos($name, Facebook_Stream::$input_prefix) !== FALSE) {
             $stream[substr($name, strlen(Facebook_Stream::$input_prefix))] = $value;
         }
     }
     Fire::info($stream, 'strpos');
     $stream = $this->explodeTree($stream, '-');
     Fire::info($stream, 'tree');
     $stream = array_intersect_key($stream, $this->_stream);
     Fire::info($stream, 'intersect');
     Fire::info($this->_stream, '_stream');
     $this->_stream = Arr::merge($this->_stream, $stream);
     Fire::info($this->_stream, 'merge');
     if (isset($this->_stream['attachment'])) {
         $this->_attachment->values($this->_stream['attachment']);
     }
     Fire::info($this);
     return $this;
 }