ShowTable of Contents
Debugging
Use the following code at the very beginning of your App (after including yn/yn_base.js) to enable basic debug logging in the YouAtNotes Framework:
ynSession.setDebug(true);
true is equivalent to debug level 1, so you can use ynSession.setDebug(1), too.
You can set a finer debug level with debug levels 2 or 3:
ynSession.setDebug(2); // finer level
ynSession.setDebug(3); // finest level
Furthermore, you can use the debug level for your own debug messages by simply calling YN.log(msg, level):
YN.log("my debug message for basic debug mode", 1);
YN.log("my debug message for fine debug mode", 2);
YN.log("my debug message for finest debug mode", 3);
Writing a logfile
You can enable logging to a file with
ynSession.setDebug(level, true);
with <level> as a debug level as defined above.
The logfile will be created in the App's data directory and named "ynlog-YYYYMMDDHHMMSS.log".
WARNING!
Logfiles are never deleted automatically! If you leave logging enabled all the time in a production App, this could lead to a huge waste of filesystem space on the device!
Exception handling
You should sourround all code with exception handlers like this:
try {
...
} catch (e) {
YN.exception("message", e);
... other code if neccessary ....
}
for example in a function:
function myFunction() {
try {
... code ...
} catch (e) {
YN.exception("myFunction", e);
return false;
}
}
If something goes wrong in your code, execution jumps to the catch() handler. YN.exception() prints he message and the error to the log.