Juliatzin
Juliatzin

Reputation: 19695

Imposible to see Logs with Titanium Appcelerator ( Web apps)

I'm new to appcelerator dev, I develop in native android and wanted to discover Appcelerator. I'm doing a very easy app, and I'm testing in as a webapp ( it's faster than android) The problem is I can't find a way to display logs. I intented :

 Ti.API.info('test');

or

 console.log("My variable is " );

I can't find a way to print it in console, I've checked all consoles ( Studio Console, DDMS ( I installed it), FastDev), nothing display.

I don't do it with android emulator, because it takes a lot of time, when I do it with android, I can see logs :Ti.API.info('test');

Is there a way to do it with webapps??? I use Titanium Studio, build: 3.1.3.201309132423

Tx

Upvotes: 3

Views: 952

Answers (1)

Markive
Markive

Reputation: 2400

I had the same problem, in order to log things from your WebView layer you need to fire an event that calls up to the Titanium layer and then logs to the console, something like this:

In your Titanium layer (for example where you add the WebView):

var log = function(e) {
   Ti.API.info(e.log);
};
Ti.App.addEventListener('weblog', log);

Then in your Webview javascript:

Ti.App.fireEvent('weblog', {log:'Your console message here.. Or count:' + myObj.length});

Don't forget to remove this global eventListener when you close the Window..

If you are debugging through TiStudio you should see the logs in the console, otherwise run Android Monitor (android/tools/monitor) and see it in the log of your connected device.

Upvotes: 2

Related Questions