flaps-logger
v1.0.1
Published
A Advanced Logger that logs colorized messages
Downloads
1
Readme
Table of contents
FlapsLogger
A Advanced Javascript Utility Logger.
How to use
install the package into your project
npm install flaps-logger
After installing import and create the Logger by using the createLogger function
const FlapsLogger = require("flaps-logger");
const logger = FlapsLogger.createLogger(options);
to Log something use the either info, warn, error, failure, debug to log something into the console about something in your code
logger.info("Hi from FlapsLogger");
You should see this in the terminal.
[$DATE] / INFO: Hi from FlapsLogger
And your done.
Use Log files
to use log files you gotta edit the options.
const Logger = FlapsLogger.createLogger({ writeLogFile: true });
This will make the logger write to a file called log.txt
to Change the name of the file use the FlapsLogger#setLogFile function
Logger.setLogFile(pathLike);
And now if you send out something into the console it should be written to a log file named whatever you set it.
Updating Logger format
to Update logger's format update the options format function.
const Logger = FlapsLogger.createLogger({ format: (type, message, date) => {
return `${type}: ${message} / ${date}`; // This is an example
}});
Now when ever you write something or use the log functions it should use your format.