/**
 * Implements the Cold Fusion Function writeoutput
 */
package railo.runtime.functions.other;


import java.io.PrintStream;

import railo.runtime.PageContext;
import railo.runtime.ext.function.Function;

public final class SystemOutput implements Function {
    public static boolean call(PageContext pc , String string) {
        return call(pc, string, false,false);
    }
    public static boolean call(PageContext pc , String string, boolean addNewLine) {
        return call(pc, string, addNewLine, false);
    }
    public static boolean call(PageContext pc , String string, boolean addNewLine,boolean doErrorStream) {
    	PrintStream stream = System.out;
    	//string+=":"+Thread.currentThread().getId();
    	if(doErrorStream) stream = System.err;
        
    	if(addNewLine)stream.println(string);
        else stream.print(string);
        return true;
    }
}
/**
 * Implements the Cold Fusion Function writeoutput
 */
package railo.runtime.functions.other;


import java.io.PrintStream;

import railo.runtime.PageContext;
import railo.runtime.ext.function.Function;

public final class SystemOutput implements Function {
    public static boolean call(PageContext pc , String string) {
        return call(pc, string, false,false);
    }
    public static boolean call(PageContext pc , String string, boolean addNewLine) {
        return call(pc, string, addNewLine, false);
    }
    public static boolean call(PageContext pc , String string, boolean addNewLine,boolean doErrorStream) {
    	PrintStream stream = System.out;
    	//string+=":"+Thread.currentThread().getId();
    	if(doErrorStream) stream = System.err;
        if("<print-stack-race>".equalsIgnoreCase(string)){
        	new Exception("Stack trace").printStackTrace(stream);
        	if(addNewLine)stream.println();
        }
        else {
        	if(addNewLine)stream.println(string);
        	else stream.print(string);
        }
    	return true;
    }
}
add posibility to print the current stacktrace via function SystemOutput