Logging of variable
Posted: Fri Sep 08, 2023 11:30 am
Hi
I have made a small script, which takes an URL and encodes it with "encodeURI". See code below.
It fails if I try to log the encoded URL.
If I do no logging it works and sets the private data correctly.
I get this error:
In this test, the encoded URL is set to "https://www.skabertrang.dk/en%20lille%20test".
Should the log not be able to show this?
I have made a small script, which takes an URL and encodes it with "encodeURI". See code below.
It fails if I try to log the encoded URL.
If I do no logging it works and sets the private data correctly.
I get this error:
Code: Select all
Invalid placeholders in log message
at Object._0x4028cb [as _log] (C:\Program Files\Enfocus\Enfocus Switch\ScriptExecutor\nodemodules\node_modules\switch-scripting\index.js:727:23)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async _0x48bf25.log (C:\Program Files\Enfocus\Enfocus Switch\ScriptExecutor\nodemodules\node_modules\switch-scripting\index.js:2735:17)
at async jobArrived (D:\Switch-Scripts\EncodeURL\main.js:1:982)
at async _0x45c618 (C:\Program Files\Enfocus\Enfocus Switch\ScriptExecutor\nodemodules\node_modules\switch-scripting\index.js:1278:28)
at async D:\Switch-Scripts\EncodeURL\main.js:1:3352
Should the log not be able to show this?
Code: Select all
async function jobArrived(s: Switch, flowElement: FlowElement, job: Job) {
let URLtoEncode: string = await flowElement.getPropertyStringValue("URLtoEncode") as string;
let PDKey: string = await flowElement.getPropertyStringValue("PDKey") as string;
// Encode complete URL
let encodedURL: string = await encodeURI(URLtoEncode) as string;
await job.log(LogLevel.Info, "URL to encode: \"" + URLtoEncode + "\"");
await job.log(LogLevel.Info, "Encoded URL: \"" + encodedURL + "\"");
await job.setPrivateData(PDKey, encodedURL);
await job.sendToData(Connection.Level.Success);
}