Search code examples
ibm-mobilefirstworklight-adaptersconsole.log

console.log in worklight procedure


my procdure in sql adapter is given below

var procedure1Statement = WL.Server.createSQLStatement("select * from userreg ");
function procedure1() {
var resp= WL.Server.invokeSQLStatement({
    preparedStatement : procedure1Statement,
    parameters : []
});


    var a=resp.resultSet;
    var name=new Array();
    for(var i=0;i<a.length;i++){

         name[i]=a[i].name;

    }
    //return (name);
    //alert (name);

    console.log( name.toString());
}

if i call this procedure can i display name values in browser console,

or if i use WL.logger.log() instead of console.log


Solution

  • You cannot use console.log in server-side code... you must have code in the client-side that will receive the response from this server-side code (that is - you must return it), and then you could use console.log (and other options) - in the client-side - to print the values to the console in your browser or LogCat or other tools...

    What you can do in the case of adapter logging or debugging, is to use WL.Logger.warn or WL.Logger.error to print out to the Eclipse console.

    See this question for more information on the above: IBM Worklight 6.0 - How to enable/view WL.Logger.debug in adapters?