Difference between revisions of "Tutorials webOS Debugging 101"
(adding/organizing debugging help for newbies) |
m (Added logging options for JSON values.) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | If your results are not what you expected, use JavaScript's try/catch/finally block statements to localize the problem. The first thing you want to do is get as close as possible to where you believe the error is occurring. If you're not sure where, start at the beginning. | ||
+ | |||
+ | |||
Add mojo.logs to your code and evaluate them in putty. | Add mojo.logs to your code and evaluate them in putty. | ||
− | Mojo.Log.error("****V" + " my variable: " + this.variable ); | + | Mojo.Log.error("****V" + " my variable: " + this.variable ); |
+ | Alternatively you can use Mojo.Log.error("my JSON variable: %j", this.jsonObject); or Mojo.Log.error("my JSON variable: "+ JSON.stringify(this.jsonObject)); to log JSON Objects. | ||
putty.exe | putty.exe | ||
(for emulator) | (for emulator) | ||
− | ip address "localhost" port 5522 | + | <p>ip address "localhost" port 5522</p> |
− | connection type: ssh | + | <p>connection type: ssh</p> |
− | when command line opens type root | + | <p>when command line opens, type <code>root</code></p> |
− | no password just hit enter | + | <p>no password just hit enter</p> |
− | type: | + | <p>type: <code>grep payment /var/log/messages</code></p> |
− | "payment" is the string you are searching for with grep | + | <p>"payment" is the string you are searching for with grep</p> |
− | after you log in to putty: | + | <p>after you log in to putty:</p> |
− | + | <p>Mojo.Log.error writes to /var/log/messages</p> | |
− | + | <p>grep: searches for the string following grep within the file specified after the search string, and prints out those lines</p> | |
− | grep: searches | ||
− | |||
− | SIDE NOTE: if you copy text into the clipboard, you can paste it into putty by right-clicking in putty. | + | <p>SIDE NOTE: if you copy text into the clipboard, you can paste it into putty by right-clicking in putty.</p> |
Latest revision as of 14:29, 25 July 2011
If your results are not what you expected, use JavaScript's try/catch/finally block statements to localize the problem. The first thing you want to do is get as close as possible to where you believe the error is occurring. If you're not sure where, start at the beginning.
Add mojo.logs to your code and evaluate them in putty.
Mojo.Log.error("****V" + " my variable: " + this.variable );
Alternatively you can use Mojo.Log.error("my JSON variable: %j", this.jsonObject); or Mojo.Log.error("my JSON variable: "+ JSON.stringify(this.jsonObject)); to log JSON Objects.
putty.exe (for emulator)
ip address "localhost" port 5522
connection type: ssh
when command line opens, type root
no password just hit enter
type: grep payment /var/log/messages
"payment" is the string you are searching for with grep
after you log in to putty:
Mojo.Log.error writes to /var/log/messages
grep: searches for the string following grep within the file specified after the search string, and prints out those lines
SIDE NOTE: if you copy text into the clipboard, you can paste it into putty by right-clicking in putty.