Best Practices for Debugging a Javascript Transform


#1

I have a custom javascript transform that isn’t producing any types.

When I run SourceFile.process(), it returns no errors.

I thought I’d be able to put a breakpoint in the transform from the tools in console, but it didn’t initiate debugger.

What’s the best method for debugging something like this?


#2

The best debugging method is the plain old logging/tracing (ask elders). First you insert at the beginning of a js file

var log = C3.logger('myLogger');

and then call, for example,

log.warn('## myState: {}', JSON.stringify(myState, null, 2));

If you do not want to mess with log levels, use a high enough one. I prepend ## so that I can paint such lines in my terminal. If you use a server, search your logs in Splunk.