Sun Java System Portal Server 7.1 Developer's Guide

Reporting Errors to the Robot Log File

When problems occur, robot application functions should return an appropriate response status code (such as REQ_ABORTED), and they should also log an error in the error log file.

To use the error-logging functionality, you must include the file log.h in the PortalServer-base/sdk/robot/include/libcs directory.

After you have ensured that log.h exists in the correct place, you can use the cslog_error macro to report errors. The prototype is in the following format:

cslog_error(int n, int loglevel, char* errorMessage)

The first parameter is not currently used (may be used in the future) You can pass this as any integer.

The second parameter is the log level. When the log level is less than or equal to the log level setting in the file process.conf, the error message is written in the robot.log.

The third parameter is the error message to print, and it has the same form as the argument to the standard printf() function.

For example:


cslog_error(1, 1, ("fn=extract-html-text: Out of memory!\\n"));

         

This invocation of cslog_error would generate the following error message in the robot log file:


[22/Jan/1998:15:57:31]  8270@0: ERROR: fn=extract-html-text: Out of memory!

For another example:


cslog_error(1, 1,
    ("<URL:%s>: Error %d (%d): %s\\n",
    ep->eo->key,
    urls->server_status,
    status,
    (s = cslog_linestr(urls->error_msg)))

This invocation of cslog_error would generate the following error message in the robot log file:


[22/Mar/2002:15:57:31]  8270@0: ERROR: <URL:http://budgie.siroe.com:80/>:
Error 0 (-240): Can’t connect to server