thehatrack

Chrome Logger API for ColdFusion

About two weeks ago, I spotted a link on either Reddit or Hacker News to a Google Chrome extension called Chrome Logger. I immediately saw the potential, because I frequently want to cfdump something but have to either abort immediately after or worry about my dump disappearing into a thread, screwing up my layout, etc., etc. There were libraries available for PHP, Python, and Ruby at the time (Node was added recently as well), so I figured I may as well jump on board and put one together for CF.

I finished my preliminary work on the component last weekend and used it at work all week, fixing bugs as I came across them. I'm now reasonably confident that it can be put into the wild, so I'm pleased to announce version 0.1 of chromelogger-cf, hosted at http://www.github.com/s992/chromelogger-cf.

In addition to logging simple values, structs, arrays, and queries, I've also added a method to convert objects (primarily ORM entities) into a struct representation, including relationships. I imagine this is where most of the bugs will surface, so please don't hesitate to open an issue if you run into some weirdness.

Ok, enough of the boring stuff - let's see how this thing actually works!

The most basic logging is accomplished via chromelogger.log(). Simply pass in any number of arguments and check the Chrome console.

This results in the following output to the console:

screenshot

Of course, if you don't want all your logged items on one line, you can call log() as many times as you want:

screenshot

In addition to log(), you also have the option to warn() and error():

screenshot

You can also group your logs using group() or groupCollapsed(), followed by any number of log(), warn(), or error() calls, and finally a groupEnd():

screenshot

Don't forget about objects and exceptions (note that the recursion between User and Address is caught and handled):

screenshot

Stucts, arrays, and queries are supported too:

screenshot

So, there you have it. Check out the project on GitHub for (a little) more documentation and to get started!

Comments

Chris Tierney
April 22, 2013, 12:36 PM

This is great Sean! I may suggest that you make this browser safe in your examples... for instance:

if (!window.chromelogger) chromelogger = {log: function() {}};

Chris Tierney
April 22, 2013, 12:39 PM

My comment may have been a little two quick as my head was in JavaScript land.

Sean
April 22, 2013, 3:17 PM

Thanks for the comment, Chris. As you've already discovered, this is a CFC - nothing to do with JS. :)

Dan Vega
April 23, 2013, 1:50 PM

Pretty cool stuff Sean, thanks for starting this!

Raymond Camden
April 23, 2013, 8:55 PM

Very cool. We should package this up with the DevTool tab thing I did - http://www.raymondcamden.com/index.cfm/2012/8/24/First-release-of-ColdFire-for-Chrome.

Sean Walsh
April 23, 2013, 10:57 PM

@Dan - Thanks, I hope it works well for you. You know where to find me if you have any issues!

@Ray - That would be pretty neat! I didn't write the Chrome extension for this, just the CFC that interfaces with it, so I'm not sure what would be involved there.

Connor Middleton
April 24, 2013, 10:05 AM

Ray, that link in your comment has a period at the end, throwing it off a bit.

Post a Comment
  1. Leave this field empty

©2014 theHATRACK