isLogPropertySet
Checks if a custom logging property has been defined.
Syntax
Copy
function isLogPropertySet(key: string): boolean
| Parameter | Description |
|---|---|
key
|
Custom key to be included in the log message properties. |
Return Value
Returns a boolean indicating if the custom property has been defined.
Examples
In this example:
- We use the ftos.logging.setProperty function to define a custom log property called fooKey and assign it the fooValue value.
- We define the x variable to confirm that the fooKey custom property has been defined.
- We use the getLogPropertyValue function to store the key's value in the y variable.
- We use the yValue variable to store the state of the property.
- We ftos.logging.log a message that emphasizes the state of the fooKey custom property.
Copy
setLogProperty('fooKey', 'fooValue');
var x = isLogPropertySet('fooKey');
var y = getLogPropertyValue('fooKey');
var yValue = x && y!=null ? 'is set.' : 'is not set.';
log('The fooKey custom property ' + yValue);
The resulting log message will be similar to the one below:
Copy
-[START]---------------------------------------
Timestamp: 17/12/2021 02:10:56 PM
Message: The fooKey custom property is set.
Severity: Information
Exception:
Properties: { CorrelationId: "23cdb1f5-0529-4377-b200-399efb8bc32f", PortalProfile: null, MachineName: "FTOSBUCLP385", Language: "en-GB", Source: "Platform", fookey: "fooValue", automationscript: "sample-script-log-api" }
-[END]---------------------------------------