Logging not working through js files

Hi guys,

I tried to call the logging mechanism from within the hello.js script that is provided in Files. Hitting the URL properly responds with “Hello World!” but my log file doesn’t update.

Logging does seem to work from my iOS app, though.

Here is my code:


exports.run = function ( request, response )
{
    var logger = Backendless.Logging.getLogger("com.mbaas.Logger")
    logger.info("Hello, world!");


    response.send( "Hello, world!" );
};

Hi Gal,

I was able to reproduce the problem. We will look into it and report back.

Regards,
Mark

Actually, now none of my js files work… I tried to run hello.js and I get an error:

https://api.backendless.com/2E0275F5-389B-C759-FFE9-CFE090864D00/v1/files/web/scripts/hello.js

Error: EIO, i/o error ‘/repo/web/scripts/hello.js’

Here are the contents of the scripts:

https://develop.backendless.com/console/2E0275F5-389B-C759-FFE9-CFE090864D00/appversion/6EB0C351-79F7-7F92-FF04-BB8339CD9100/qpfdjrgoysozsqkeckbrhlkiitjjdkbxpbyo/files/view/web/scripts/hello.js

To be sure I also tried to get the public URL for the Shopping cart example files, and they all say I have an “unexpected token: o”

Some more info:

As soon as I hit “Save” on a JS file, even if I had no made any changes, the i/o error appears. I diff-ed an example file, setquantity.js before saving with a version after, they are identical, but one no longer works and returns 500s. Tried both POST and GET.

Hi Gal,
thank you for reporting, we have already fixed running js files and have a fix for logging, but it’s not in production yet and we will notify you very soon when it’s ready.
For now I can suggest you a workaround.
Upload the latest backendless.js (take it from here: https://github.com/Backendless/JS-SDK ) to ‘node_modules’ folder. Then in your logger file put in the top next rows:

var Backendless = require('backendless');
var APPLICATION_ID = 'your_app_id';
var SECRET_KEY = 'your_secret_key';
var VERSION = 'your_version';
Backendless.initApp(APPLICATION_ID, SECRET_KEY, VERSION);

And then run it again as you did it before.
Hope it helps.
Let me know if everything is ok.

Regards,
Stanislav

Is the fix for this on production yet?

Yes,
could you try it?

Sorry, I still don’t see any logging going on.

exports.run = function ( request, response )
{
var logger = Backendless.Logging.getLogger(“com.mbaas.Logger”)
logger.info(“Hello, world!!!”);
response.send( “Hello, world!!” );
};

Hi Gal,

Please make sure to set the logging policy so the log messages are flushed right away to the service:
Backendless.Logging.setLogReportingPolicy(1, 0);

Mark

Hi,

the logs are still not working. Any updates?

Test code:

exports.run = function ( request, response )
{
var logger = Backendless.Logging.getLogger(“com.mbaas.Logger”)
Backendless.Logging.setLogReportingPolicy(1, 0);
logger.info(“test1”);
logger.info( “informational log message” );
logger.warn( “warning message” );
logger.debug( “debug message” );
logger.error( “error message” );
response.send( “Hello, world!! 1” );
};

https://api.backendless.com/2E0275F5-389B-C759-FFE9-CFE090864D00/v1/files/web/scripts/hello.js

Any idea for other solutions? without the logs or a debugger I’m coding blind here (the JS code hosting). I have an external log set up, which failing silently as well… can’t debug that either :frowning: