Win an Ipad
  Developer   Documents   Debug and log utilit ...

Debug and log utilities

This document explains how to use debug tools, log utilities, global objects and functions designed to find and isolate problems with your code.

Debug and log utilities

Build-in global variable console is a great way to debug application and log information. Text sent to console can be viewed in IDE Console pane (docked in the bottom-left side of IDE).

 


There are some build-in global functions and statements that provide additional debug information. All script objects have function show(), which displays a list of functions, properties and their values.

Note: Only script objects provide show(), there is no such method for native objects, or it exists in a different way for this purpose (e.g. Dialog.show() shows the UI dialog). See example:

var obj = {
   firstName: "Jozef",
   nickName: "Oxy",
   age: 33
}; obj.show();

displays

Class Object: [object Class]
    Properties:
        age: 33
        nickName: "Oxy"
        firstName: "Jozef"

In the framework, there is a set of functions designed to work with IDE and logs information of several severity levels. To access this feature you need to include “lib://core/log.ms” file.

  •     logI(); - Logs debug string with severity  I - Information to Moscrif - IDE console
  •     logW(); - Logs debug string with severity  W - Warning to Moscrif -IDE console
  •     logE(); - Logs debug string with severity  E -Error to Moscrif -IDE console
  •     log(); - Logs debug string without any severity

 

include "lib://core/log.ms"; var i = 10;
var pt = {x: 10, y: 20};
var str = "Hello"; logI(i, str);
logW(String.printf("Warning: pt=%V", pt));
logE("File not found!"); log(i, pt, str);

Shows following text in the Console pane:

Log-I:    07:42.475    10 Hello Log-W:    07:42.476    Warning: pt={y:20,x:10} Log-E:    07:42.476    File not found! Log-I:    07:42.476    10,[object Object],Hello

 Moscrif emulation   Debug and log utilities   Custom splash screen 
Write a Comment (0)
Subject
Please complete this mandatory field.
HTML Tags Not Allowed!
Comment
Please complete this mandatory field.