Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 1.36 KB

README.md

File metadata and controls

33 lines (25 loc) · 1.36 KB

LiteLogger

Usage

For use in Nodejs to create daily logs with time stamps for your application.

To use:

Install the NPM package:

npm i @kingdanx/litelogger

Create a new LiteLogger object:

const logger = new LiteLogger(__dirname, "Test Dir", "Test Logs");
//The first argument is the name of the directory. 
//The second argument is the name of the folder you want your files in. It will be created if it does not exist
//The third argument is the name attached to the .log files

This logger object would create a directory and files that look like this:
image

Call the log() method:

logger.log({ test: "test" }, "ERROR");
logger.log("test");
//The first argument is the message you want to log.
//The second argument is a string value that defines the message type. If not provided it will be of type INFO

Here is the expected output from the above code:
image

If the log() function is called on a day for which no log file exists, a new file will be created to store all messages received on that day. If log() is called on a day that already has an associated file, the message will be appended to that file.