AddTraceLog
You can use the AddTraceLog function to record performance tracing and diagnostic messages in the Optiva tracing tables (FsActionWIPTrace for workflows and FsObjectSymbolTrace for object operations). This function helps developers monitor execution flow, measure performance, troubleshoot issues, and understand code behavior during development and troubleshooting.
Note:
- Calling this function from a workflow adds an entry to the FsActionWIPTrace. The tracing records are displayed in the .
- Calling this function from an object hook script, equation, or copy method adds an entry to the FsObjectSymbolTrace table. These tracing records are displayed in .
When to use
You can use this function when:
- To track execution time and identify performance errors.
- To trace workflow execution flow and identify the executed code path.
- To diagnose issues in production environments when the is selected.
When not to use
You cannot use this function:
- To track execution time and identify performance errors.
- To trace workflow execution flow and identify the executed code path.
- To diagnose issues in production environments when the checkbox is selected.
Syntax
int AddTraceLog(string Message);
Parameter
| Parameter | Type | Required | Description |
|---|---|---|---|
| Message | string | Yes | The custom meesage for log tracing. |
Return Value
The application returns a value greater than zero (0) if Trace log is added successfully.
Prerequisites
- You must set the ScriptTrace.Enable profile attribute to 1 to enable the check box on the Action Set, Equation, Copy Method, and Symbol form.
- You must select this checkbox to record an entry in the corresponding tracing table after the script execution completes in Optiva. You can use this function with the
AddTraceLogcommand.
Examples
- Example 1
-
Basic Usage
using System; using Formation.Shared.Defs; class ActionScript : FcProcFuncSetEventWF { public long wf_start() { // Log the start of the workflow AddTraceLog("Starting workflow execution"); // Perform some business logic int result = ProcessOrder(); // Log the result if (result > 0) AddTraceLog("Order processed successfully. OrderID: " + result); else AddTraceLog("Order processing failed"); // Log completion AddTraceLog("Workflow execution completed"); return 1L; } }