Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to watch console.logs in ionic emulator?

I'm building an app using the Ionic framework, which I've done in the browser until now. Because I now want to use the cordovaOauth plugin I need to use the emulator. The problem is that I can't see any console.log() in the emulator as I do in the browser, which makes it hard to debug.

Does anybody know how in Ionic/Cordova I can make use of console logging in the emulator? All tips are welcome!

like image 876
kramer65 Avatar asked Feb 19 '15 16:02

kramer65


People also ask

How do you find the ionic log of a console?

From that device list click on "Inspect" button on the right side of that device name(check screenshot for the same) will open a new window with your device mirror now console is yours play around with this debugger.

How do I check my console on emulator?

To access it, open the Chrome Developer tools from the More tools menu. Inside it you need to open the Remote devices view from the More tools menu. The view will list all attached Android devices and running emulator instances, each with its own list of active web views.

How do I debug an ionic app on emulator?

Developer Options & USB Debugging are enabled by default in the Android emulator. Open the Chrome browser and navigate to the URL chrome://inspect/#devices . Your connected Android device should show up in the list of Remote Targets. On your device, open the Ionic app that you would like to debug using Chrome.


2 Answers

Just enable the console logs in the emulator. Here my example:

> ionic emulate ios --livereload    Setup Live Reload   Running dev server: http://localhost:8100   Adding in default Ionic hooks   Running live reload server: http://localhost:35729   Watching : [ 'www/**/*', '!www/lib/**/*' ]   Ionic server commands, enter:     restart or r to restart the client app from the root     goto or g and a url to have the app navigate to the given url     consolelogs or c to enable/disable console log output     serverlogs or s to enable/disable server log output     quit or q to shutdown the server and exit 

Type consolelogs in the command line and hit enter.

  consolelogs    Console log output: enabled   Loading: /?restart=382451   ionic $ 0     498458   log      Hi there! This is from console.log 
like image 198
Carlos Morales Avatar answered Sep 22 '22 07:09

Carlos Morales


run ionic emulate ios -l -c

This will open the emulator with livereload feature, and you'll see all the console logs in the terminal. To turn the console logs off (or on) just write consolelogs or just c in the terminal while the ionic server is running

Another very convenient way to debug your app when using iOS emulator/device is using the Safari developer tools

When the app runs - enter Safari and choose "Develop > iOS Simulator > your page"

If you work with a real device you'll see the device's name instead of "iOS Simulator"

If you don't see the "Develop" menu in safari - enter Safari's preferences and enable it from the "advanced" tab

like image 44
Yaron U. Avatar answered Sep 23 '22 07:09

Yaron U.