1.0.0 • Published 2 years ago

node-lighthouse-error-log v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

node-lighthouse-error-log

A function which calls a lighthouse log api

Motivation

Instead of calling lighouse log api all the time. Why not to call one function which can manage all our work for logs.

Getting started

What you need before use ?

You need to register with this Light house portal http://lighthouse.itpathsolutions.com:9011/login. Then you need to add your project with in portal and get your Project Key and Deliverable Key. Now you have to put these keys into .env file into your peoject's root folder.

Installation

$ npm i node-lighthouse-error-log

ENV setup

.env

PROJECT_KEY=your project key
DELIVERABLE_KEY=your deliverable key

Usage

const { Log } = require("node-lighthouse-error-log");

Example

const { Log } = require("node-lighthouse-error-log");

exports.controller = () => {

    try {
        // code
    }
    catch ((error) => {
        this.ErrorLog({
            error: error,
            logType: 5, 
            headers: {
                "Content-Type": "application/json"
            },
            method: "GET",
            endPoint: "http://127.0.0.1:8000/api/test/addLog",
            requestIp: "192.168.1.55"
        }).then(res => {
            console.log(res, "res")
        }).catch(err => {
            console.log(err, "res")
        })
    })
	
};

Props

PropsDescriptionExample
errorError trace object
logTypeThe value can be 1 for debug, 2 for warning, 3 for notice, 4 for info, 5 for error , default = 55
methodHttp request methodGET, POST, PUT, etc.
endPointHttp API endpointhttp://127.0.0.1:8000/api/test/addLog
requestIpHttp request ip address192.168.1.1

Thanks

Our implementation was inspired by http://lighthouse.itpathsolutions.com:9011/guide/api