PHP Класс lithium\analysis\logger\adapter\FirePhp

This allows you to inspect native PHP values and objects inside the FireBug console. Because this adapter interacts directly with the Response object, some additional code is required to use it. The simplest way to achieve this is to add a filter to the Dispatcher. For example, the following can be placed in a bootstrap file: {{{ use lithium\action\Dispatcher; use lithium\analysis\Logger; Logger::config(array( 'default' => array('adapter' => 'FirePhp') )); Dispatcher::applyFilter('_call', function($self, $params, $chain) { if (isset($params['callable']->response)) { Logger::adapter('default')->bind($params['callable']->response); } return $chain->next($self, $params, $chain); }); }}} This will cause the message and other debug settings added to the header of the response, where FirePHP is able to locate and print it accordingly. As this adapter implements the protocol specification directly, you don't need another vendor library to use it. Now, in you can use the logger in your application code (like controllers, views and models). {{{ class PagesController extends \lithium\action\Controller { public function view() { ... Logger::error("Something bad happened!"); ... } } }}} Because this adapter also has a queue implemented, it is possible to log messages even when the Response object is not yet generated. When it gets generated (and bound), all queued messages get flushed instantly. Because FirePHP is not a conventional logging destination like a file or a database, you can pass everything (except resources) to the logger and inspect it further in FirePHP. In fact, every message that is passed will be encoded via json_encode(), so check out this built-in method for more information on how your message will be encoded. {{{ Logger::debug(array('debug' => 'me)); Logger::debug(new \lithium\action\Response()); }}}
См. также: lithium\action\Response
См. также: lithium\net\http\Message::headers()
Наследование: extends lithium\core\Object
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_counter integer This self-incrementing counter allows the user to log more than one message per request.
$_headers array These headers are specified by FirePHP and get added as headers to the response.
$_levels array This is a mapping table that maps Lithium log levels to FirePHP log levels as they do not correlate directly and FirePHP only accepts a distinct set.
$_queue Contains messages that have been written to the log before the bind() call.
$_response Holds the response object where the headers will be inserted.

Открытые методы

Метод Описание
bind ( object $response ) : void Binds the response object to the logger and sets the required Wildfire protocol headers.
write ( string $priority, string $message ) : boolean Appends a log message to the response header for FirePHP.

Защищенные методы

Метод Описание
_format ( string $type, string $message ) : array Generates a string representation of the type and message, suitable for FirePHP.
_write ( array $message ) : array | void Helper method that writes the message to the header of a bound Response object. If no Response object is bound when this method is called, it is stored in a message queue.

Описание методов

_format() защищенный Метод

Generates a string representation of the type and message, suitable for FirePHP.
protected _format ( string $type, string $message ) : array
$type string Represents the message priority.
$message string Contains the actual message to store.
Результат array Returns the encoded string representations of the priority and message, in the `'key'` and `'content'` keys, respectively.

_write() защищенный Метод

Helper method that writes the message to the header of a bound Response object. If no Response object is bound when this method is called, it is stored in a message queue.
См. также: lithium\analysis\logger\adapter\FirePhp::_format()
protected _write ( array $message ) : array | void
$message array A message containing the key and the content to store.
Результат array | void The queued message when no `Response` object was bound.

bind() публичный Метод

Binds the response object to the logger and sets the required Wildfire protocol headers.
public bind ( object $response ) : void
$response object An instance of a response object (usually `lithium\action\Response`) with HTTP request information.
Результат void

write() публичный Метод

Appends a log message to the response header for FirePHP.
public write ( string $priority, string $message ) : boolean
$priority string Represents the message priority.
$message string Contains the actual message to store.
Результат boolean Always returns `true`. Note that in order for message-writing to take effect, the adapter must be bound to the `Response` object instance associated with the current request. See the `bind()` method.

Описание свойств

$_counter защищенное свойство

This self-incrementing counter allows the user to log more than one message per request.
protected int $_counter
Результат integer

$_headers защищенное свойство

These headers are specified by FirePHP and get added as headers to the response.
protected array $_headers
Результат array

$_levels защищенное свойство

This is a mapping table that maps Lithium log levels to FirePHP log levels as they do not correlate directly and FirePHP only accepts a distinct set.
protected array $_levels
Результат array

$_queue защищенное свойство

Contains messages that have been written to the log before the bind() call.
protected $_queue

$_response защищенное свойство

Holds the response object where the headers will be inserted.
protected $_response