Difference between revisions of "Patch webOS Logging Information from Within Scripts"

From WebOS Internals
Jump to navigation Jump to search
(New page: One of the most basic forms of debugging information available is to print a message. By liberally scattering such print statements throughout code, you can see the value of certain varia...)
 
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
{{template:patch}}
 
One of the most basic forms of debugging information available is to print a message.  By liberally scattering such print statements throughout code, you can see the value of certain variables within your code.  Mojo provides this functionality using the the equivalent of Unix syslog from within applications.
 
One of the most basic forms of debugging information available is to print a message.  By liberally scattering such print statements throughout code, you can see the value of certain variables within your code.  Mojo provides this functionality using the the equivalent of Unix syslog from within applications.
  
Line 7: Line 8:
  
 
Mojo supports three levels of logging at this time: Mojo.Log.error, Mojo.Log.warning and Mojo.Log.info.  These correspond to the values 0, 10 and 20, respectively.  If you change that logLevel to a value greater than 0, 10 or 20, then **all** of that level and lower Mojo.Log statements will log each time that application is run.  At this time it appears that a reboot of the Pre is required to cause this change to take effect.  As logging consumes resources, it is suggested that once you complete your debugging, you reset the value back to zero and reboot your Pre to clear logging.
 
Mojo supports three levels of logging at this time: Mojo.Log.error, Mojo.Log.warning and Mojo.Log.info.  These correspond to the values 0, 10 and 20, respectively.  If you change that logLevel to a value greater than 0, 10 or 20, then **all** of that level and lower Mojo.Log statements will log each time that application is run.  At this time it appears that a reboot of the Pre is required to cause this change to take effect.  As logging consumes resources, it is suggested that once you complete your debugging, you reset the value back to zero and reboot your Pre to clear logging.
 +
 +
NB: It may be necessary to change the logLevel value to a much higher value, eg. 99.
  
 
Once the value has been changed and the Pre rebooted, Mojo.Log output values will be visable in ///var/log/messages//.  An easy way to watch them is to ssh into your rooted Pre and type
 
Once the value has been changed and the Pre rebooted, Mojo.Log output values will be visable in ///var/log/messages//.  An easy way to watch them is to ssh into your rooted Pre and type

Latest revision as of 17:34, 6 December 2011


One of the most basic forms of debugging information available is to print a message. By liberally scattering such print statements throughout code, you can see the value of certain variables within your code. Mojo provides this functionality using the the equivalent of Unix syslog from within applications.

Looking in the home directory of an application, you should see a file named //framework_config.json//. An example of a full path to this file would be ///usr/palm/applications/com.palm.app.messaging/framework_config.json//. A stock version of this file will most likely contain the sequence:

{
    "logLevel": 0
}

Mojo supports three levels of logging at this time: Mojo.Log.error, Mojo.Log.warning and Mojo.Log.info. These correspond to the values 0, 10 and 20, respectively. If you change that logLevel to a value greater than 0, 10 or 20, then **all** of that level and lower Mojo.Log statements will log each time that application is run. At this time it appears that a reboot of the Pre is required to cause this change to take effect. As logging consumes resources, it is suggested that once you complete your debugging, you reset the value back to zero and reboot your Pre to clear logging.

NB: It may be necessary to change the logLevel value to a much higher value, eg. 99.

Once the value has been changed and the Pre rebooted, Mojo.Log output values will be visable in ///var/log/messages//. An easy way to watch them is to ssh into your rooted Pre and type

tail -f /var/log/messages

which will generate a scrolling log of this file including the Mojo.Log messages (as well as additional system information). To stop the tail, use ^C (Control-C).

In its most basic form, Mojo.Log simply concatenates together the passed values and prints them. Some additional formatting options are available, see the file ///usr/palm/frameworks/mojo/submissions/175.7/javascripts/log.js// on your Pre for additional information.