Log and Notification Functions

Log and Notification Functions

The following Log and Notification functions are used for debugging APL code or logging user-defined messages and events.

debug

This function prints the supplied argument to the output target specified in the Execution tab of the Workflow Properties dialog. The valid options are File or Event.

If File is selected, the debug is saved in the temporary directory specified in the system property pico.tmpdir. The file must be named debug/<workflow name>.

Alternatively, the location of the debug file can also be configured by using the mz.wf.debugdir property. Each time a workflow is activated, a new debug information will be generated and overwrite the existing file.

If Event is selected, the output is shown in the Workflow Monitor. For further information, see https://infozone.atlassian.net/wiki/spaces/MD95/pages/574784312.

void debug( arg )

Parameter

Description

Parameter

Description

arg

Argument to write to debug output. Could be any type. Note that printing a UDR type will dump all the field values, which may be a large amount of data. Similarly, the debug output for a table or list type may be very large.

There is a special case if arg is a bytearray. In this case, the output string will be the hex dump returned from the baHexDump built-in function.

For all other variable types, the output is the direct string conversion, meaning debug ( arg ) is the same as debug( (string) arg ).

Returns

Nothing

Note!

If the Enable Debug option has not been enabled when you start the workflow, then the debug statement will be ignored and the argument will not be evaluated.

dispatchAlarmValue

The function makes it possible to detect alarm situations based on workflow behavior. It dispatches a user defined <value> with a user defined valueName from the workflow. The valueName used must be defined using Alarm Detection. For further information, see https://infozone.atlassian.net/wiki/spaces/MD95/pages/574981047 in the Desktop user's guide.

void dispatchAlarmValue(string <"valueName">, long value)

Parameter

Description

Parameter

Description

"valueName"

The workflow alarm value name, as defined in the Alarm Detection Editor

value

Any value to be associated with the name

Returns

Nothing

Example - Using dispatchAlarmValue

The following code example displays a situation and syntax useful for the dispatchAlarmValue.

consume { if ( timeToPay ) { udrRoute(chargingUdr, "to_billing"); //Enable for 'amount out of range' Alarm Detection dispatchAlarmValue("chargingAmount", chargingUdr.amount); } }

dispatchEvent

A user can define a customized event type. This is done using an event UDR, optionally extended with user-defined fields. This event UDR can be populated with any information by using APL code, and then be sent, using the dispatchEvent function, to be caught by the Event Notification.

The event will have asynchronous event handling, and if there is an error in the notification, or if dispatching is on the way, this will be logged in either the EC log or the Platform log, depending on what the problem is.

For further information about Event Notification, see https://infozone.atlassian.net/wiki/spaces/MD95/pages/575112018 in the Desktop user's guide.

void dispatchEvent( UltraEvent eventUDR )

Parameter

Description

Parameter

Description

eventUDR

The name of the event UDR

Returns

Nothing

dispatchMessage

This method is used to produce user-defined messages associated with predefined Event Categories. For further information about the Event Notification editor, see https://infozone.atlassian.net/wiki/spaces/MD95/pages/575112018 in the Desktop user's guide. For instance, an Event Category could be named 'DISASTER' and be configured to send an email to the System Administrator. Then an APL agent could send a detailed description with the dispatchMessage function whenever this error situation is detected.

void dispatchMessage ( string string , string <Event Category> )

Parameter

Description

Parameter

Description

string

Value/message to append to the Event Category

<Event Category>

Name of a user-defined event as declared in the Event Notification Editor. This event must be defined in the Event Notification Editor for the APL code to compile.

Returns

Nothing

log*

Logs a message string to the System Log of type error, warning, or information. The entry will fall under the Workflow category, where the workflow name will be the name of the current workflow, and the agent name will be the name of the agent logging the message.

Note!

The System Log is primarily used to monitor system health and all issues related to the stability of all the Pico instances in the environment. These could be issues or errors about the Platform or ECs that require the operator’s attention.

It is recommended that you do not log anything that may not be crucial to the System Log. This may be information about processing progress, processing results, reporting, or summaries, as this information should be kept out of the System Log. You may use the dispatchMessage function or https://infozone.atlassian.net/wiki/spaces/MD95/pages/575112018 to help keep track of such information.

Using the system log in a non-recommended way may cause extra strain on the Platform and database storage. This may cause troubleshooting of any MediationZone issue to be harder and more time consuming.

void logError ( string message , string parameterName_n , // Optional string|int parameterValue_n , // Optional ... ) void logInformation ( string message , string parameterName_n , // Optional string|int parameterValue_n , // Optional ... ) void logWarning ( string message , string parameterName_n , // Optional string|int parameterValue_n , // Optional ... )

Parameter

Description

Parameter

Description

message

A main message appearing in the log

parameterName_n

Name of an optional parameter. If declared, parameterValue_n must be declared as well.

parameterValue_n

Value of an optional parameter. If declared, parameterName_n must be declared as well.

Returns

Nothing

Example - Using logWarning

The following code example logs a warning message, which, when displayed in the System Log, will look like the following figure:

logWarning( "UDR failed validation", "ANUMBER IS ", input.anum, "BNUMBER IS ", input.bnum, "DURATION IS ", input.duration);
System Log inspection

log.*

These functions invoke logging with log4j. For information about how to configure the logging, such as to set the log level, see the https://infozone.atlassian.net/wiki/spaces/MD95/pages/575152415.

void log.fatal (any message, any tag ) //optional void log.error (any message, any tag ) //optional void log.warn (any message, any tag ) //optional void log.info (any message, any tag ) //optional void log.debug (any message, any tag ) //optional void log.trace (any message, any tag ) //optional

Parameter

Description

Parameter

Description

message

A value that will be appear in the message field in the log output
This parameter will be ignored if it cannot be typecast to a primitive data type, for example, string or int.

tag

Objects(s) that will appear in the tag field in the log output.

Returns

Nothing

Example - Using log.debug

consume { log.debug("In consume."); list<int> rcDebug =listCreate(int); int rc=0; listAdd(rcDebug,rc); rc=1; listAdd(rcDebug,rc); log.debug(rc,rcDebug); }

mailNotify

Sends an email to a configured recipient. In order to operate, the system must have an email remitter and an SMTP mail server defined. For further information on Platform properties, see https://infozone.atlassian.net/wiki/spaces/MD95/pages/574825573 in the System Administrator's Guide.

Warning!

If used within the consume block, make sure that conditional expressions guarantee that this function does not get called for each UDR.

void mailNotify ( string address , string subject , string message , string sender , //Optional list<string> attachment ) //Optional

Parameter

Description

Parameter

Description

address

Email address to the recipient on the form: "user@xxx.com"

subject

Text ending up as the email subject

message

Message string ending up as the body of the email

sender

Name or address of the sender of the email

Note!

Optional

This field will remain optional only when the attachment field is not populated. Once the attachment is populated, the sender field will be a mandatory field.

attachment

A list that will contain one or many attachments to be sent with the email. Each list entry will be the full directory path of the attachment. The example path could look like:

Example - Attachment

"/home/admin/attachments/word.txt"

Returns

Nothing

mailNotifyHtml

Sends an email in HTML format to a configured recipient. In order to operate, the system must have an email remitter and an SMTP mail server defined. For further information on Platform properties, see Platform in the System Administrator's Guide.

Warning!

If used within the consume block, make sure that conditional expressions guarantee that this function does not get called for each UDR.

void mailNotifyHtml ( string address , string subject , string message , string sender , //Optional list<string> attachment ) //Optional

Parameter

Description

Parameter

Description

address

Email address to the recipient on the form: "user@xxx.com"

subject

Text ending up as the email subject

message

Message string ending up as the body of the email

Note!

Supports standard HTML content.

sender

Name or address of the sender of the email

Note!

Optional

This field will remain optional only when the attachment field is not populated. Once ‘attachment’ is populated, the sender field will be a mandatory field.

attachment

A list that will contain one or many attachments to be sent with the email. Each list entry will be the full directory path of the attachment.

Example - Attachment

"/home/admin/attachments/word.txt"

Returns

Nothing