Logging Adventures

Is ServiceNow you don’t really have a debugger that you can use to trace what’s happening in your code. Instead, most people spend a lot of time using logging statements.

I’ve gotten into the habit of using JSON.stringify(object, null, 2) to convert objects to something that can be logged out. I ran into an occasion recently where my logging statements were logging out an object that was missing a bunch of information on it.

Pro tip: (/sarcasm) Maps don’t convert and print via a JSON.stringfy, so if you have an object that contains a map, you’ll have to try something else :).