Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic: where to see the displayed console log

I am new to ionic I am following ionic framework documents to learn it.

Here is my method's code: hello-ionic.ts

  openActionSheet(){
    let actionSheet=this.actionsheetCtrl.create(
    {
        title: 'Modify your album',
        cssClass: 'page-hello-ionic',
        buttons:[
          {
            text: 'Delete',
            role: 'destructive', //will always sort to be on top
            icon: !this.platform.is('ios') ? 'trash' : null,
            handler: () => {
              console.log('Delete clicked');
            }
          },
          {
          text: 'Play',
          icon: !this.platform.is('ios') ? 'arrow-dropright-circle' : null,
          handler: () => {
            console.log('Play clicked');
          }   
        },
        {
          text: 'Favorite',
          icon: !this.platform.is('ios') ? 'heart-outline' : null,
          handler: () => {
            console.log('Favorite clicked');
          }
        },
        {
          text: 'Cancel',
          role: 'cancel', // will always sort to be on the bottom
          icon: !this.platform.is('ios') ? 'close' : null,
          handler: () => {
            console.log('Cancel clicked');
          }
        }
      ]});
    actionSheet.present();
  }
  

The code works fine. But I want to know that where is console.log() printed. Can anyone help me with that?

like image 671
Riddhi Avatar asked Mar 16 '18 08:03

Riddhi


People also ask

How to check logs in Ionic?

To access the logs open Android Studio, click the logcat in the bottom toolbar and then in the logcat window, select your device and provide the filtering options and log level(info, error).

How to use console log in Ionic?

To see it on the browser you need to open the debugging console. To do so do a right click and then click on the "Inspect" option. To use the console. log("hello") from your Ionic app, just add this line anywhere in your code.

How do I preview an Ionic app?

Preview URL App Mode​ You can switch between previewing different modes of your application by clicking the "iPhone" dropdown in the top right of the Web preview. This allows you to choose other devices like Android or a tablet.


1 Answers

To check the console log you can use browser and run the below command:

Step 1: $ionic serve (will run your app on localhost)

Step 2: In your respective browser (chrome, safari, etc...) where your app is running Right + click and inspect your app as per below screenshot.

enter image description here

Step 3: You will get a window with HTML elements on the right side of your browser window and on the left your app screen.

enter image description here

Step 4: On the right side window, you can find "Console" menu option on the top bar. Click on that you will get your console where you find your app logs or error or warning which ionic generated.

enter image description here

enter image description here

EDIT: Real Device or Emulator debugging

To check real-device or emulator or genymotion console logs follow the below steps & screenshots.

Step 1: Run this command to run your app on real-device or emulator

$ionic cordova run android

Step 2: After successfully launch the app on device or emulator Go to Chrome browser and Right + click and click on "Inspect" and you will get below screen at bottom of your browser.

enter image description here

Step 3: Click on "Remote devices" will show connected real device or emulator list.

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.

enter image description here

enter image description here

Hope this will help you to debug your app.

like image 116
CodeChanger Avatar answered Oct 20 '22 17:10

CodeChanger