/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 */
package org.thingml.compilers.javascript.node;

import org.thingml.compilers.Context;
import org.thingml.compilers.javascript.JSThingActionCompiler;
import org.thingml.xtext.thingML.ErrorAction;
import org.thingml.xtext.thingML.Expression;
import org.thingml.xtext.thingML.PrintAction;

/**
 * Created by jakobho on 28.03.2017.
 */
public class NodeJSThingActionCompiler extends JSThingActionCompiler {

    @Override
    public void generate(ErrorAction action, StringBuilder builder, Context ctx) {
    	for (Expression msg : action.getMsg()) {
		    builder.append("process.stderr.write(''+");
		    generate(msg, builder, ctx);
		    builder.append(");\n");
    	}
    	if (action.isLine())
    		builder.append("process.stderr.write('\\n');\n");
    }

    @Override
    public void generate(PrintAction action, StringBuilder builder, Context ctx) {
    	for (Expression msg : action.getMsg()) {
	        builder.append("process.stdout.write(''+");
	        generate(msg, builder, ctx);
	        builder.append(");\n");
    	}
    	if (action.isLine())
    		builder.append("process.stdout.write('\\n');\n");
    }
}

@@ -1108,744 +1108,7 @@
 %0D%0A%0D%0A
-    @Override%0D%0A    public void generate(ErrorAction action, StringBuilder builder, Context ctx) %7B%0D%0A    %09for (Expression msg : action.getMsg()) %7B%0D%0A%09%09    builder.append(%22process.stderr.write(''+%22);%0D%0A%09%09    generate(msg, builder, ctx);%0D%0A%09%09    builder.append(%22);%5Cn%22);%0D%0A    %09%7D%0D%0A    %09if (action.isLine())%0D%0A    %09%09builder.append(%22process.stderr.write('%5C%5Cn');%5Cn%22);%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    public void generate(PrintAction action, StringBuilder builder, Context ctx) %7B%0D%0A    %09for (Expression msg : action.getMsg()) %7B%0D%0A%09        builder.append(%22process.stdout.write(''+%22);%0D%0A%09        generate(msg, builder, ctx);%0D%0A%09        builder.append(%22);%5Cn%22);%0D%0A    %09%7D%0D%0A    %09if (action.isLine())%0D%0A    %09%09builder.append(%22process.stdout.write('%5C%5Cn');%5Cn%22);%0D%0A    %7D%0D%0A
 %7D%0D%0A

Use console.log and console.error