This module is responsible for all the system logging. It has two goals : - add levels - link it with logDNA
We use Winston and the logs are sent to logDNA.
You just need to add the npm package :
npm install https://github.com/tgorka/logpapaya --save
Or using yarn
yarn add https://github.com/tgorka/logpapaya --save
In your index.js you need to initiate the module and give the logDNA key.
import { logging } from "logpapaya";
logging.init({
app: "the name of your app",
env: "the environnement you use can be anything",
key: "Your logDNA key"
}, "hostname / can be anything / production . dev . test");
Now it is ready to use
The levels used are the following :
- error
- warn
- info
- verbose
- debug
- silly
By default this system will be used and sent to logDNA
If you put the hostname equal to "production" only the following levels will be considered:
- error
- warn
- info
For each of one of the levels we have a method:
import { logging } from "logpapaya";
//For example for the error level
logging.error("Something went wrong");
//"Something went wrong"
If you add a second argument it will appear as a title:
import { logging } from "logpapaya";
//For example for the error level
logging.error("Something went wrong", "module1");
// -->module1<-- "Something went wrong"