LogJson(filePath, data) Last updated: 11. Oct 2024

API only function

Creates a new JSON array file or adds a new item to the existing array in the file. This function works as a log, maintaining an array of events. The server automatically adds a timestamp to each log entry.

Parameters

Name Type Description
filePath string The absolute path where the JSON log file will be saved or updated in Docly. Ensure the path is correct and includes the desired filename with a .json extension.
data object The new event data to be added to the log. This object will be appended to the existing array in the file, or create a new array if the file doesn't exist. The server automatically adds a timestamp to each log entry.

Returns

Returns a reference to the updated log file, including a unique GUID for the file, allowing for easy identification and retrieval.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// This will add a new event to the JSON log file in Docly
let newEvent = { "action": "User login" };
docly.logJson("Logs/UserActions.json", newEvent);