CloudLogger enables you to perform logging operations easily and quickly in your JavaScript and TypeScript projects. This package facilitates logging operations by sending requests to CloudLogger service running on the server side.
You can add the package to your project using npm or yarn package managers:
npm install @viovnl/cloudlogger
or
yarn add @viovnl/cloudlogger
Or you can include the script in your HTML:
<script src="https://cdn.statically.io/gh/VIOVNL/CloudLogger-NPM/main/dist/index.global.min.js"></script>
To use CloudLogger, you will need a Project secret. Obtain your project secret from CloudLogger Website.
// Include the CloudLogger package in your project
const CloudLogger = require('@viovnl/cloudlogger');
// Create an instance of CloudLogger and configure it
const cloudLogger = CloudLogger.Create('your_project_secret');
// Create an instance of CloudLogger and configure it
const cloudLogger = CloudLogger.Create("your_project_secret");
// Import CloudLogger from the 'cloudlogger' package
import CloudLogger from '@viovnl/cloudlogger';
// Create an instance of CloudLogger and configure it
CloudLogger.Create('your_project_secret');
CloudLogger.Create('your_project_secret', { ThrowExceptionOnFailure: true });
Creates a new instance of CloudLogger with the provided project secret and options.
Your CloudLogger project secret. Obtain your project secret from CloudLogger Website.
Parameter | Type | Default Value | Description |
---|---|---|---|
ThrowExceptionOnFailure | boolean | false | Specifies throwing an exception in case of failure. If ThrowExceptionOnFailure set to true, an exception is thrown when the logging operation fails. If set to false, an error will be written in console. |
Performs the logging operation.
// Perform the logging operation
CloudLogger.Log([
{ Name: "Date", Value: "22-10-1994" },
{ Name: "Country", Value: "Netherlands" },
]);
// Prepare the items you want to log
const logItems: CloudLoggerItem[] = [
{ Name: "Date", Value: "22-10-1994" },
{ Name: "Country", Value: "Netherlands" },
];
// Perform the logging operation
CloudLogger.Log(logItems);
// Perform the logging operation and throw an exception if it fails, disregarding global ThrowExceptionOnFailure setting.
CloudLogger.Log([
{ Name: "Date", Value: "22-10-1994" },
{ Name: "Country", Value: "Netherlands" },
], true);
// Perform the logging operation and don't throw an exception if it fails, disregarding global ThrowExceptionOnFailure setting.
CloudLogger.Log([
{ Name: "Date", Value: "22-10-1994" },
{ Name: "Country", Value: "Netherlands" },
], false);
Parameter | Type | Description |
---|---|---|
Name | string | The name of the column in the project where the data will be logged. Ensure that the provided name matches the column name exactly as defined in the project. |
Value | any | The data to be logged into the specified column of the project. It is imperative to ensure that the data logged aligns precisely with the designated data type specified for the column. |
Parameter | Type | Default Value | Description |
---|---|---|---|
throwExceptionOnFailure | boolean | CloudLoggerOptions.ThrowExceptionOnFailure | Specifies throwing an exception in case of failure. If throwExceptionOnFailure set to true, an exception is thrown when the logging operation fails. If set to false, an error will be written in console. |
Updates the project secret for the CloudLogger instance, enabling logging to a different project.
// Update the project secret
CloudLogger.UpdateProjectSecret("your_project_secret");
You can check out different demos we have prepared for you under the demo
folder.
Install the dependencies:
npm install
Run the demo:
npm run dev
Install the dependencies:
npm install
Run the demo:
npm run dev
Install the dependencies:
npm install
Run the demo:
node index.js
Launch the file in your browser to see the demo in action.