Strange Symphonies Don’t worry, be happy

28Jun/070

FirebugLogger Released

So I finally decided to release one of my toy Rails plugin to the public, hoping that someone besides me can benefit from it.

My Rails development consists of using multiple screens, with one running tail -f logs/development.log . Now the problem I found with Rails development is that the logs were hard to read/decipher through. Sure you can trim them in various ways, but when you want things fast and instant, its a bit tedious. Especially when you are debugging a page, and breakpoints are not available to you. (Darn you v1.8.5!)

One of my favorite tools for web development is Firebug, a Firefox extension that makes web development a whole lot easier. Its terrific for debugging JavaScript and Ajax, modifying the DOM tree and bending it to your will, and generally all around awesome!

I decided to create a simple plugin that would log things to the Firebug console. Actually its very simple, just save the log calls and output them to the view! It's more like a hack! But hey it does its job.

Example

Now FirebugLogger isn't the same as the default Logger. In the Controller a new object, firebug, is exposed for you to submit your logs.

class UsersController < ApplicationController
  def index
    firebug.log 'This seems like a good thing to do'
    firebug.debug 'Why I can be easily debugging with this thing!'
    firebug.info "Oh this looks like its very informative, doncha think?"
    firebug.warn 'Danger Will Robinson, Danger!'
    firebug.error "Oh noes I'm going to explode!"
  end
end

Inside your View you just have to place:

<%= firebug_logs %>

After it is all baked and done, here is a screenshot for you:
FirebugLogger

If you are familiar with PHP development, then you'd probably know about the echo/var_dump type of debugging. But you can't do that in Rails, thus the intention for this plugin was something like that. At least it doesn't break your beautiful pages :) .

But it is also smart in that it won't display anything in your test or production environments. (You could if wanted to). So you can leave the logs there without worrying too much.

I opted not to mix it with the default Logger as I didn't want the ActionController or ActiveRecord logs filling up the JavaScript console! If I wanted that I could just tail the logs, which I already do.

Now FirebugLogger does not seek to replace breakpointer, nor is it supposed to replace the default Logger.

You can find out more information about FirebugLogger here. But there isn't really much more to it.

Note: You don't need Firefox to you use Firebug, you can replace it Firebug Lite.

Here are some more screenshots of it running using Firebug Lite in Safari, Internet Explorer 7, and Opera.
FirebugLogger - Safari FirebugLogger IE7 FirebugLogger Opera

Installation

Installing FirebugLogger is just like installing any other plugin:

./script/plugin install git://github.com/aizatto/firebug_logger.git

Or if your project is in subversion you can add the -x flag.

License

FirebugLogger is released under the MIT license.

Related posts

Tags

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.