1.17.0 • Published 5 years ago
personalized-logger v1.17.0
Personalized Logger
It is personalized method to Log messages in both console and file. The first version contemplates a simple idea of logging using the below formatting:
timestamp - Level - SubLevel - Machine Hostname - Process ID - Conversation ID: content
Levels
- SYSTEM - It contemplates how the system works;
- ENDPOINT - It contemplates the health of the application endpoints when it receive requests and send responses;
- BUSINESS - It contemplates the business rules in the application;
Sublevels
It contemplates what kind of information exists in each Level.
- INFO;
- WARN;
- ERROR;
How to use Personalized Logger
First step - Installing:
npm i --save personalized-logger
Second step - Adding the component:
const Logger = require("personalized-logger");
or
import Logger from "personalized-logger";
Third step - Using in application:
Logger.system(`${conversationID}`, `${contentMessage}`, `${subLevel}`);
/*
* this is a simple example using SYSTEM level logging but in all levels function
* the same parameter are used
*/
How to call each level of log
Each level logging is represented by a function with the name of the level, in the above example, we used SYSTEM as a level but you can do with the other ones like the below examples:
Logger.endpoint(`${conversationID}`, `${contentMessage}`, `${subLevel}`);
or
Logger.business(`${conversationID}`, `${contentMessage}`, `${subLevel}`);
All functions receive the same three parameters:
- conversationID - The ID of the conversation that is currently using our application;
- contentMessage - A message defined by the user (DEV) to define the context of the log itself;
- subLevel - The default sublevels listed before, the default sublevel is INFO;