The Log object allows JavaScript functions to log messages to the Rhapsody log files.
The use of loggers in production scenarios with high traffic volumes can result in Rhapsody running out of disk space.
Methods
Method |
Description |
---|---|
|
Logs the object's string representation to the Rhapsody log file. The object's |
|
Logs the object's string representation to the Rhapsody log file. The object's This information is only added to the log if the Rhapsody log-level is set to DEBUG or higher. |
|
Logs the object's string representation to the Rhapsody log file. The object's |
|
Logs the object's string representation to the Rhapsody log file. The object's This information is only added to the log if the Rhapsody log-level is set to INFO or higher. |
|
Logs the object's string representation to the Rhapsody log file. The object's |
|
Logs the object's string representation to the Rhapsody log file. The object's This information is only added to the log if the Rhapsody log-level is set to WARN or higher. |
|
Logs the object's string representation to the Rhapsody log file. The object's |
|
Logs the object's string representation to the Rhapsody log file. The object's This information is only added to the log if the Rhapsody log-level is set to ERROR or higher. |
|
Logs the object's string representation to the Rhapsody log file. The object's |
|
Logs the object's string representation to the Rhapsody log file. The object's This information is only added to the log if the Rhapsody log-level is set to FATAL. |
|
Logs the object's string representation to the Rhapsody log file. The object's This information is only added to the log if the Rhapsody log-level is set to TRACE or higher. |
Example
The following example displays how the Log object can be used in a JavaScript filter. This code processes a message normally, but logs the value of a field AcknowledgementCode
in the MSA
segment, at the WARN log level. An appropriate message definition is required to be associated with the route.
for (var i = 0; i < input.length; i++) { var next = output.append(input[i]); log.warn("Value of MSA.AcknowledgementCode is " + next.getField("MSA.AcknowledgementCode")); }
Filter Exceptions and Errors
A filter that indicates errors by calling Message.addError()
, or by throwing an exception out of the filter, has its errors available through the getErrors()
method available in JavaScript.
- If any exception is thrown out of a filter while processing a message, the exception message and the name of the filter are added as an error to the message, allowing subsequent retrieval using the
getErrors()
method. - If the exception has a nested cause (for example, a nested exception), all the messages from the nested exceptions are also added as errors to the message (identified as nested exceptions).
- If an exception is thrown out of a filter, any other changes made to the message by the filter are discarded.
- If the thrown exception is a
FilterProcessingException
(or a derived class), this indicates an error with the message, so the message is sent to the error connector of the filter. - If the thrown exception is any other type, the message is sent directly to the error queue (as it generally indicates an issue with the filter rather than the message).
- If the message is sent to the error connector, but there is nothing connected to the error connector for this filter, the message is sent to the error queue.
- If an exception is thrown when there were multiple input messages (for example, a collector), the exception error messages are added to all the input messages and all messages are sent to the error connector or error queue.
- If a filter explicitly adds errors to the message using the
addError()
method, the message is sent to the error connector once it leaves the filter. Unlike when an exception is thrown, any changes made to the message in this case are saved (as the filter did complete execution).