Debug Server Side Javascript (controller)?


#1

Is there a way to debug serverside javascript. I can debug the java code in my app, but have do I setup it to debug SSJS ?


Way to debug controllers
#2

Hi,

I recommend putting a utilities JavaScript file in the resources/cms/lib folder that has this function in it:

exports.log = function (data) {
    log.info('Debug log %s', JSON.stringify(data, null, 4));
}; 

Then you can require this utilities file in each controller.js and use it like this:

var util = require('utilities');
util.log(fooBar);

This will give you a readable JSON output for objects. If you want to check the value of a variable that is not an object then it is simpler to use:

log.info(fooBar);

We also have a Utilities project on Github that has a log function and a lot of other useful functions. You can include those files in your own project with a Gradle configuration. The instructions are in the README.


#3

OK, Thank you.
I’m aware of this funstionality and uses it a lot. But where how to do this: http://blog.jetbrains.com/idea/2014/03/debugger-for-jdk8s-nashorn-javascript-in-intellij-idea-13-1/


#4

I only have the community edition of IntelliJ and that type of debugging is not possible without the Ultimate edition. Maybe one of our other developers knows about this.


#5

We are testing out how to debug server side scripting in IntelliJ. It’s one bug (or missing feature) in IntelliJ right now and that’s on how they resolve the actual javascript file. We need to think of something smart here to make this work.

But, we are on it and it would be awsome if it worked! :slight_smile:


#6

Any updates on it? (It would be awesome to have debug in IntelliJ for server side js)


#7

@srs Is debugging serverside javascript possible now ? Can’t get it too Work.


#8

Sadly it’s problematic with IntelliJ. It’s working partly, but not good enough. Netbeans is the only one that works perfectly. We will have a guide up to show how to set up debugging. Will be before 6.11 release.


#9

Hi,

How can I check that JSON file with the error?

Regards.