Logging Processor MessagesIt's also possible to log XSLT activity and then send this information to a log file for later analysis. The function that lets you accomplish this is named xslt_set_log(), and it needs to be invoked twice: first to enable XSLT logging and then to set the name of the log file to write processor messages to. The first time xslt_set_log() is called, it requires two parameters: a handle representing the XSLT processor to track, and a Boolean value to enable logging:
The second time the function is invoked, the first parameter remains the same; however, the second parameter is now the name of the file to write log messages to:
This is very simple and works like a charm. Listing 4.6 puts it in context. Listing 4.6 Logging XSLT Processor Messages
And here's an excerpt from the resulting log file:
This excerpt is not very useful at the moment, but expect the log messages to get more descriptive as the API evolves. If the second argument to xslt_set_log() the name of the log fileis absent (or NULL), errors are written to the standard error display (usually the browser running the script). If the specified log file already exists, new messages are appended to the end of the log.
It should be noted that xslt_set_log() merely provides a mechanism to log processor messages. It does not catch or log errors in syntax; in order to catch these, you need to use one of the error-handling mechanisms described in the "Handling Errors" section. |