The log object allows messages to be stored as your scripts are executed. By choosing an appropriate message the significance of the messages can be specified, allowing you to distinguish between debugging and informational messages and between warnings, and severe or fatal errors.
Messages recorded with the log object are available to you from the Error Logs tab of the Application administration panel.
Note that logging messages are recorded when the statement is executed, not when the script it is in is evaluated. Consider the following example of a page script:
// Page Script:
log.info('Evaluating the script containing the display function');
function display() {
log.info('Executing the display function');
try {
log.info('Preparing to render the page');
renderer.display();
log.info('Page rendered OK');
} catch( e ) {
log.severe('Rendering FAILED with an exception: ' + e);
}
}
When the page script is evaluated the first log message will be recorded. None of the other logging messages will be recorded until the display function is executed.
At present the only practical difference between the various functions is the category information stored with them. This is used to select the icon for display in the logging administration page. At some point we will probably add the ability to filter the logging messages more aggressively and possibly to enable and disable logging of some categories (debug messages for example). The better you adhere to the suggested usages below the easier it will be to maintain your Chrome Server applications in the long term.
Log a debugging message to be viewed in the administration panel
Debugging messages are used to inspect the state of your scripts as you develop them. When you are finished with the development process you should remove debug logging messages.
Log an informational message to be viewed in the administration panel
Record informational messages for events that you want to keep track of via the administration panel but for which you don't need special reporting logic. For example, you might log the creation of new users so that you can easily see registrations in your application without creating a page and supporting logic to extract the information from your database.
Log a warning message to be viewed in the administration panel
Use this function to record problems which are unexpected but not likely to cause long-term problems.
Log a severe error message to be viewed in the administration panel
Log a fatal error message to be viewed in the administration panel
We recommend that you use invoke this function only in circumstances where significant unrecoverable errors have occurred - for example where data that was expected to be in the database is missing.