FireLogger – a sexy server logger console in Firebug

FireLogger – a sexy server logger console in Firebug

FireLogger is a Firefox+Firebug addon which provides logging functionality similar to Firebug’s console.log. It sends logging events to a client-side encoded in HTTP headers.

I always really liked an idea of debugging through headers, mostly because you are able to log directly to Firebug and it makes debugging of live sites invisible. I came across this tool by searching for Firephp alternatives, since Firephp never could properly handle redirection logging and I believe latest Companion versions are overcomplicated.

This tool comes from Python world originally, it seems that it was called FirePython at start?! Anyway, I was testing it for a few days and it really works great, it’s stable and easy to use, complements to the author.

You can install it from official or Firefox addon page and it requires Firebug to work:
http://firelogger.binaryage.com/
https://addons.mozilla.org/en-us/firefox/addon/firelogger/

The tool adds another tab in Firebug named Logger in which you can see logs sent from code. If you’re dumping objects or arrays, you just click “more” and variables are shown in right Watchers window. If you click Persist button, logs stays there on redirect/reload, similar as Net functionality in Firebug.

For some reason, current 1.0 version didn’t worked on FF 3.X versions for me, it seems FF 4.X is required. Also, be sure that “Show User-defined properties” is checked on Watchers tab (check screenshot), otherwise you won’t see variables when clicking more in logger window.

Php library is well written, there is only one file you need to include in your projects and you’re good to go. It requires PHP 5.3 or higher and it’s nice example of register_shutdown_function usage.

require 'firelogger.php';
flog("Hello world!");

It can be found at:
github.com
http://firelogger.binaryage.com/#php

Here is simple example I patched up together for testing purposes, to check how it works in Magento, maybe someone is interested: Weiler_FireLogger_example.zip

Mage::helper('firelogger')->log('Hello world!');
$product = Mage::getModel('catalog/product')->load(100);
Mage::helper('firelogger')->debug($product);

Enjoy!

You made it all the way down here so you must have enjoyed this post! You may also like:

Unit testing in Magento 2 Andrija Glavas
Andrija Glavas, | 0

Unit testing in Magento 2

Taking control over module upgrade process Stjepan Udovicic
, | 3

Taking control over module upgrade process

Getting things in Magento by getModel and getData methods Stjepan Udovicic
, | 13

Getting things in Magento by getModel and getData methods

13 comments

  1. I tried it with my development website, But can’t see anything in firelogger. I have PHP 5.3.13 and magento 1.5.1. I tried few random tweaks but none works. Please tell me if there is anything specific I need to do.
    Also checked that firelogger and system logger are enabled from admin.
    There is no error although.
    Test website url is bombaybeautystore.com/dev in case you want to have a look.

    Thanks

  2. FireLogger updated to v.1.1, working great with FF6 !! Download from their page.

    @Mondane: I was using FirePhp for some time, it’s mentioned in the article

  3. @Toni (our SEO guy): Thanks for changing post image. This is now definitely hottest Inchoo article 🙂

  4. Yes, it works fine for me. If you’re missing object/array dumps under Watchers tab (second screenshot) when clicking more, be sure that “Show User-defined properties” is checked on Watchers tab.

    I believe multiple ob_start()-s will work fine, not sure why they wouldn’t ?! I would do the same if I need some global lib that manipulates headers, I would force ob, and if it’s called few times, everything should be flushed at script end (I’m thinking out loud here 🙂 ).

    They are checking headers_sent() on shutdown, if the content is sent that should take care of it. But I also think that trigger_error is a bit too much there.

    I’m glad you like it !! I started using it on daily basis.

  5. Did you manage to get it working?
    For me it displays just the format string, and not the data..

    Also, if you notice, the PHP library uses ob_start() to capture the content so it can send the headers before flushing it… won’t work if your app uses ob_start() by itself, and there’s a hack required to disable this and run the encoding handler manually..

    $_SERVER['HTTP_X_FIRELOGGER'] = null;                        define('FIRELOGGER_NO_OUTPUT_HANDLER', 1);
    define('FIRELOGGER_NO_CONFLICT', 1);
    include_once "firelogger.php";
    FireLogger::$enabled = true;

    They need to add a condition around last register_shutdown_function()

    It’s interesting that they provide FIRELOGGER_NO_OUTPUT_HANDLER but don’t take care of disabling encoding on shutdown, i.e. when the content was already sent.

    Unless I missed something?

    Otherwise, nifty little add-on.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.