FirePHP::Dispatcher - sends log messages to a FirePHP console
use FirePHP::Dispatcher; my $fire_php = FirePHP::Dispatcher->new( $reference_to_http_headers_of_current_request ); $fire_php->log( 'Hello world' ); $fire_php->start_group( 'Levels:' ); $fire_php->info ( 'Log informational message' ); $fire_php->warn ( 'Log warning message' ); $fire_php->error( 'Log error message' ); $fire_php->end_group; $fire_php->start_group( 'Propably empty:' ); $fire_php->dismiss_group; $fire_php->finalize;
FirePHP::Dispatcher implements the basic interface for logging to a FirePHP console. It is no logger on its own but rather a basic API that can be used by front-end loggers to divert or copy messages to a FirePHP console.
Creates a new instance of FirePHP::Dispatcher and binds it to the HTTP::Headers object given as parameter.
FirePHP::Dispatcher
Returns: a new FirePHP::Dispatcher object
Add the needed protocol headers and meta infos to the HTTP::Headers object if anything has been logged to it. Without finalize, FirePHP will ignore all messages.
finalize
Log a plain message to the FirePHP console
Log a informational message to the FirePHP console
Returns: Return value
Log a warning message to the FirePHP console
Log a error message to the FirePHP console
Prints the FirePHP::SimpleTable or Text::SimpleTable object to the FirePHP console
Starts a new, collapsable logging group named $name. Nesting groups is entirly possible.
$name
Dismisses the current group. In later versions this will most propable delete contained messages. Right now just a warning is issued and the current group is closed with end_group.
end_group
Closes the current group and reenter the parent group if available.
Close the current group if it containes messages, otherwise just dismiss it.
Renders the message with the given attributs into a message string that is understood by FirePHP. In version 0.2 of the FirePHP protocol this means just an ordered JSON dump.
Iterator for FirePHP headers. Calling it advances the internal message cursor so ensure that you either fill it or rollback the message.
Returns: the next header field name for messages
Rolls back the last message and decreases the message cursor. This can be used to dismiss groups and delete recent messages from the stack.
CAVEAT: currently doesn't work correctly for multi-part messages that contain more than 5000 characters.
Builds the full header structure for the given message string automatically splitting it into multipart messages when the character limit of 5000 is reached. The message cursor will be advanced accordingly.
Returns: a hash containing all HTTP headers representing the given message
Just a small wrapper that builds and sends all headers for the given message.
The bound HTTP::Headers object
The number of messages already send (actually the message header cursor, you are responsible to ensure this is correct if you don't use the logging or iterator functions provided by this class)
A hasref that can be used by clients to store information about this logging session
The JSON parser in use to format messages
JSON
Internal stack used to track groups
Header: X-Wf-1-[ STRUCTURE TYPE INDEX ]-1-[ MESSAGE INDEX ]
Structure type index: 1 - LOG ( and most others? ) 2 - DUMP
Content: [TOTAL LENGTH] \| \[ \{ [JSON MESSAGE PARAMS] \} \]
Json message params: Type: LOG|TRACE|EXCEPTION|TABLE|DUMP
http://www.firephp.org, HTTP::Headers
Sebastian Willert, willert@cpan.org
willert@cpan.org
Copyright 2009 by Sebastian Willert <willert@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install FirePHP::Dispatcher, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FirePHP::Dispatcher
CPAN shell
perl -MCPAN -e shell install FirePHP::Dispatcher
For more information on module installation, please visit the detailed CPAN module installation guide.