In-line Logging

In-line Logging

From the handy tip department: It’s really nice to have built-in in-line logging for your application. I’m often asked to debug issues in StepOut’s application that would be tough to handle if I was just dropping `echo()` and `die()s` everywhere. In particular, performance issues are a pain to debug without a built-in infrastructure that can spit out performance statistics at any time.

Of course there’s XDebug, but that’s not super-easy to just plop your production application into.

Instead, we’ve just implemented a method wherein we can pass any debug information via the frontend.

Spitting out an Overview

Spitting out server performance stats


Spitting out datastore performance stats



This is all done with plain vannilla javascript methods, `` and `console.log`, with a PHP helper class on the backend that collects some performance statistics and passes it into the console for admin users.

We’ve also got a helper class that allows individual developers pass debugging information to the Console, no matter where in the PHP stack they are.

function Console::Log($str){ /* application storage code codes here }



will spit the following to the console:

Helper.php, line 32 : 0.02s – Foo

Helper.php, line 33 : 0.02s – Bar

Of course, none of this should replace a great log aggregation system. But it’s another tool that’ll allow you to diagnose performance issues in production box.

Love it, hate it? Built something better? Let me know below.

If you’re a developer who is looking to work in an efficient, fun, environment that empowers you, check out StepOut’s open positions..

Note: The usage of any information of proprietary value to my employer has been removed, and this post has been approved by my employer.

Comments are closed.