Hi! I'm currently reworking my site, so although this content is still online things may change or look odd. Please get in touch to find out how I can help you!

A Simple Helper for JavaScript Debugging via console.log

If you’re working with JavaScript in the browser, sometimes the easiest way to know what’s going on is to use console.log to output variable values or other status updates.

But as the thing you’re working on gets more complicated you can have a lot of logging going on. It’s helpful to be able to visually differentiate the different messages and/or filter them by what type of information they are.

So I wrote a little helper function to make things a bit easier:

It’s intended as a partial to be used with something like CodeKit but can just be dropped in the old-fashioned way too. It has no dependencies so should be widely compatible, though right now I've only tested it as part of a jQuery project.

It’s pretty much self-documenting so I won’t repeat what the comment says. I’ve MIT-licensed it so you’re basically free to do as you wish with it, though contributing back any improvements is always appreciated!

Tags: Debugging Development JavaScript


Sorry, feedback is now closed on this post, but please feel free to get in touch if you would like to talk about it!

Or find posts by tag →

Friends & Influences

  1. Aching Brain
  2. Andy Budd
  3. Anthony Killeen
  4. Ben Everard
  5. Cameron Moll
  6. Dan Cederholm
  7. Dan Mall
  8. Dave Shea
  9. Elliot Jay Stocks
  10. Jamie Knight
  11. Jamie Rumbelow
  12. Jason Santa Maria
  13. Jeff Croft
  14. Jeffrey Zeldman
  15. Jeremy Keith
  16. Jon Hicks
  17. Khoi Vinh
  18. Mark Boulton
  19. Matt Croucher
  20. Nocturnal Monkey
  21. Sarah Parmenter
  22. Shaun Inman
  23. Simon Collison
  24. Tim Van Damme
  25. Toby Howarth