No Console Output for Execute JavaScript for Automation

I’m using KM 8.0.4.
Even though I set display results in a window, the window doesn’t come up for console.
This used to work in earlier version.
Has something changed?

Your question/issue is not clear. Please post your macro so we can be of help.

Here it is. Nothing fancy. Just using console.log.
JXA Console Test.kmmacros (1.8 KB)

Could you please post an image of your macro?


I think I found the problem.
I noticed that in action setting, there’s an item that says include errors. If I check that, it seems to work.
Is this new feature for km 8? I didn’t have to check that in previous keyboard maestro versions.

If the action doesn’t produce any output, then the window is not displayed.

Yes, the option to include errors is new, although previously they were not included at all as far as I am aware.

Thanks @peternlewis for the reply.
That’s interesting. What constitutes as error and output?
Unless I check include errors, the window doesn’t open with even just
In previous version, the result window definitely included syntax
errors, and that’s how I fixed my script most time.

Before version 8, you could not select whether to include errors or now.

Actions created before version 8 defaulted to including the errors. Upgrades of such actions should include errors as well. Newly created actions do not include errors by default.

Errors are anything sent to STDERR. Only things printed to STDOUT are displayed.

console.log does not send anything to STDOUT, it sends it to the system log.

You can have console.log output to STDOUT by redefining it:

console.log = function() {
    for (argument of arguments) {
        $.NSFileHandle.fileHandleWithStandardOutput.writeData($.NSString.alloc.initWithString(String(argument) + "\n").dataUsingEncoding($.NSNEXTSTEPStringEncoding));
1 Like

Thanks @peternlewis for letting me know that console.log doesn’t go to
In script editor, it just prints to its console, so I assume it goes to
At least it goes to result window when you check include errors.
I’ll make a habit of checking include errors for JXA.