Like most developers, I write a lot of code.
Like all developers, sometimes my code doesn't work.
When that happens (server-side), I rely on gs.log() to spit out some information to tell me when, where, and maybe even how the error happened.
gs.log() is an extremely useful little function that is great for troubleshooting your code in dev, as well as catching unexpected behavior or circumstances in production.
For example, you might have your code run inside a try { } block, but have the following catch() { } log the error message and accompanying run-time technical details using gs.log().
Or, you might write your code so that if a function receives some unexpected data, a log entry is created with the details, while the user is informed using gs.addErrorMessage().
The problem is that whenever I make one of these logs, I find myself sifting through tens, hundreds, or even thousands of other log entries to find just the one that my code triggered - and of those, just the one that was triggered by the most recent execution of my code.
What's even worse, is if a user has to let me know about a bug or error they got, but they can only tell me that it happened "around Thursday". How am I supposed to find that log!?
Join me after the jump, and not only will I teach you how to do it, but I'll give you a file you can deploy in your instance to enable this functionality within minutes!
Read more