Log (custom log line)
function Log(line: any): void;The Log function writes a custom entry to the Syncplify Server! log. While you can pass any value (string, number, object, etc.), it is most common to log a string or a stringified object.
Unlike JavaScript's console.log(), SyncJS's Log() always works—regardless of context (synchronous or asynchronous)—and does not require a console to be available. Your log entry will be sent to the currently configured logging destination (file, syslog, stdout, etc.) as determined by your server's settings.
TIP
Use Log() for debugging, auditing, or recording important events in your scripts. Logging objects or arrays? Use JSON.stringify() for readable output.
WARNING
The Log function is often misunderstood: it does not print to a terminal or browser console, but writes to the server's log. Always check your server's log configuration to know where your entries will appear.
Parameters
| Name | Type | Description |
|---|---|---|
| line | any | The value to log. Strings, numbers, objects, etc. |
Returns
This function does not return a value.
Example
Log('Hello, world!');
var some_data = { user: 'alice', action: 'login' };
Log(JSON.stringify(some_data));