1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect2 id="zend.log.writers.firebug">
4 <title>Writing to Firebug</title>
7 <classname>Zend_Log_Writer_Firebug</classname> sends log
8 data to the <ulink url="http://www.getfirebug.com/">Firebug</ulink>
9 <ulink url="http://getfirebug.com/logging.html">Console</ulink>.
13 <inlinegraphic fileref="figures/zend.wildfire.firebug.console.png" format="PNG"
14 scale="100" width="310" />
18 All data is sent via the <classname>Zend_Wildfire_Channel_HttpHeaders</classname> component
19 which uses <acronym>HTTP</acronym> headers to ensure the page content is not disturbed.
20 Debugging <acronym>AJAX</acronym> requests that require clean <acronym>JSON</acronym> and
21 <acronym>XML</acronym> responses is possible with this approach.
31 Firefox Browser ideally version 3 but version 2 is also supported.
37 Firebug Firefox Extension which you can download from <ulink
38 url="https://addons.mozilla.org/en-US/firefox/addon/1843">https://addons.mozilla.org/en-US/firefox/addon/1843</ulink>.
44 FirePHP Firefox Extension which you can download from <ulink
45 url="https://addons.mozilla.org/en-US/firefox/addon/6149">https://addons.mozilla.org/en-US/firefox/addon/6149</ulink>.
50 <example id="zend.log.writers.firebug.example.with_front_controller">
51 <title>Logging with Zend_Controller_Front</title>
53 <programlisting language="php"><![CDATA[
54 // Place this in your bootstrap file before dispatching your front controller
55 $writer = new Zend_Log_Writer_Firebug();
56 $logger = new Zend_Log($writer);
58 // Use this in your model, view and controller files
59 $logger->log('This is a log message!', Zend_Log::INFO);
63 <example id="zend.log.writers.firebug.example.without_front_controller">
64 <title>Logging without Zend_Controller_Front</title>
66 <programlisting language="php"><![CDATA[
67 $writer = new Zend_Log_Writer_Firebug();
68 $logger = new Zend_Log($writer);
70 $request = new Zend_Controller_Request_Http();
71 $response = new Zend_Controller_Response_Http();
72 $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
73 $channel->setRequest($request);
74 $channel->setResponse($response);
76 // Start output buffering
79 // Now you can make calls to the logger
81 $logger->log('This is a log message!', Zend_Log::INFO);
83 // Flush log data to browser
85 $response->sendHeaders();
89 <sect3 id="zend.log.writers.firebug.priority-styles">
90 <title>Setting Styles for Priorities</title>
93 Built-in and user-defined priorities can be styled with the
94 <methodname>setPriorityStyle()</methodname> method.
97 <programlisting language="php"><![CDATA[
98 $logger->addPriority('FOO', 8);
99 $writer->setPriorityStyle(8, 'TRACE');
100 $logger->foo('Foo Message');
104 The default style for user-defined priorities can be set with the
105 <methodname>setDefaultPriorityStyle()</methodname> method.
108 <programlisting language="php"><![CDATA[
109 $writer->setDefaultPriorityStyle('TRACE');
113 The supported styles are as follows:
115 <table id="zend.log.writers.firebug.priority-styles.table">
116 <title>Firebug Logging Styles</title>
122 <entry>Description</entry>
128 <entry><constant>LOG</constant></entry>
129 <entry>Displays a plain log message</entry>
133 <entry><constant>INFO</constant></entry>
134 <entry>Displays an info log message</entry>
138 <entry><constant>WARN</constant></entry>
139 <entry>Displays a warning log message</entry>
143 <entry><constant>ERROR</constant></entry>
146 Displays an error log message that increments Firebug's error count
151 <entry><constant>TRACE</constant></entry>
152 <entry>Displays a log message with an expandable stack trace</entry>
156 <entry><constant>EXCEPTION</constant></entry>
158 Displays an error long message with an expandable stack trace
163 <entry><constant>TABLE</constant></entry>
164 <entry>Displays a log message with an expandable table</entry>
172 <sect3 id="zend.log.writers.firebug.preparing-data">
173 <title>Preparing data for Logging</title>
176 While any <acronym>PHP</acronym> variable can be logged with the built-in priorities,
177 some special formatting is required if using some of the more specialized log styles.
181 The <constant>LOG</constant>, <constant>INFO</constant>, <constant>WARN</constant>,
182 <constant>ERROR</constant> and <constant>TRACE</constant> styles require no special
187 <sect3 id="zend.log.writers.firebug.preparing-data.exception">
188 <title>Exception Logging</title>
191 To log a <classname>Zend_Exception</classname> simply pass the exception object to the
192 logger. It does not matter which priority or style you have set as the exception is
193 automatically recognized.
196 <programlisting language="php"><![CDATA[
197 $exception = new Zend_Exception('Test exception');
198 $logger->err($exception);
202 <sect3 id="zend.log.writers.firebug.preparing-data.table">
203 <title>Table Logging</title>
206 You can also log data and format it in a table style. Columns are automatically
207 recognized and the first row of data automatically becomes the header.
210 <programlisting language="php"><![CDATA[
211 $writer->setPriorityStyle(8, 'TABLE');
212 $logger->addPriority('TABLE', 8);
214 $table = array('Summary line for the table',
216 array('Column 1', 'Column 2'),
217 array('Row 1 c 1',' Row 1 c 2'),
218 array('Row 2 c 1',' Row 2 c 2')
221 $logger->table($table);