1.3.4 • Published 4 years ago
alertnow-js v1.3.4
alertnow-js
This package used for logging.
Installation
# using npm
npm i alertnow-js
Usage
# using require
const { setHost, setApiKey, setUser, setTag, info, error } = require('alertnow-js');
# using import
import { setHost, setApiKey, setUser, setTag, info, error } from 'alertnow-js';
Example
Using promises:
//First of all, you must set apikey and if you want, you can set user and tag infos. ApiKey is required.
setHost("<host>");
setApiKey("<api_key>");
setUser({
id: "user_id",
ipAddress: "user_ip_address",
geo: {
countryCode: "country_code",
city: "city",
region: "region"
}
});
setTag({ "property_name": "property_value" });
//You can then enter the information or error you want to log into the system using appropriate methods.
info('any information').then((response) => console.log(response));
error(new Error('Error occurred')).then((response) => console.log(response));
Using async/await:
const initializeConnection = async function () {
setHost("<host>");
setApiKey("<api_key>");
setUser({
id: "user_id",
ipAddress: "user_ip_address",
geo: {
countryCode: "country_code",
city: "city",
region: "region"
}
});
};
initializeConnection();
const createInfoLog = async function () {
const response = await info('any information');
console.log(response);
};
createInfoLog();
const createErrorLog = async function () {
const response = await error(new Error('Error occurred'));
console.log(response);
};
createErrorLog();