Showing posts with label FirePHP. Show all posts
Showing posts with label FirePHP. Show all posts

Monday, April 27, 2009

Weekend Coding

Got a couple of neat things done on the weekend.

Wrote a function to log database calls to FirePHP. Every query now logs time to execute, rows returned/affected, SQL string, function performing the call. 3 lines of code needed for each SQL call. Very nice.

EDIT - this is mainly for debugging purposes. The App itself has an internal audit trail of who changed what, and when...

Finally got around to making the app create groups automatically, based on network segment. For example, if you audit a PC that is on 192.168.0.50 255.255.255.0 the app checks if there is a group that fits these criteria (192.168.0.0/24). If it exists, the PC is added to that group, if it doesn't exist it's created and the PC added. I just have to finish the assigning of User rights to the newly created group.


As an aside, I installed Ubuntu 9.04 (Jaunty Jackalope) on the weekend. I also re-installed Windows XP. It amazes me that people say Linux is difficult to install. Obviously they haven't tried it for years. Ubuntu install == 1 hour (installed, patched, configured). Windows XP install == 4 hours (installed, patched, configured + some additional apps). Windows, with the need to install drivers and reboot, install patches and reboot and install additional applications to get a functional system, is so much slower and more difficult. I implore anyone reading this - go download Ubuntu and try it. You can do so without affecting your installed system (Ubuntu has what's called a "Live CD" - boot from it and you can try the OS without affecting your Windows install).

Ubuntu user since 5.04 and loving it more with every release. [/Zealot rant] :-)

Friday, April 3, 2009

Debug with FirePHP

I am using FirePHP to write debug messages. It works with CodeIgniter quite well. There's a simple flag (TRUE / FALSE) in a config file to enable it.

When enabled, every SQL statement along with a returned record count (in the case of a SELECT) is dumped to the console. Nice. Easy to see where you go wrong in your SQL statements. IE - "well, that query should have returned 100 rows - why is it returning 10?". It also has the nice side effect of displaying when a given query runs more than once. I had some logic in code that was causeing one SQL statement to be run 4 or 5 times. Output to the web page was fine, though. Using the FirePHP debugger, I soon realised that "Hey, how come that statement appears several times ?".

One other gotcha is that if you don't have FirePHP installed, but run with debugging on - it borks badly. I have to confirm this, but worse case... It should be off in production, anyway.

EDIT - no, it doesn't bork. It's fine to run with debug = on and not have FirePHP installed. I must have been having a bad hair day !!!

EDIT #2 - In Xampp (Windows) you need to alter the php.ini. In an Ubuntu LAMP install, you don't.

Stay tuned.