@yassinrouis/logger
v1.1.3
Published
A simple and colorful logger for NodeJS !
Downloads
79
Readme
Logger (Baby's Update - v1.0)
Table of contents
Introduction
logger
is a colorful logger for organizing your messages, and easily returning to them !
Documentation
Install
- Download from NPM :
npm i @yassinrouis/logger
- Loading and initialization:
const Logger = require("@yassin-rouis/logger");
let log = new Logger(); // Simple constructor
// or
let log = new Logger({
level: Logger.DEBUG, // Change the logging level
clear: true // Clear the console when an instance is created
})
Usage
There are 6 levels of loggings :
- Developpement :
verbose
(10)debug
(20)log
(30)
- Display :
info
(40)success
(35)
- Problems and errors :
warn
(50)error
(60)fatal
(70)
Each level can be used as follows :
// log.<level>("Your", "message", "on", "multiple \n lines")
// example :
log.log("We are", 7, "in the room !")
log.error("Can't find the eggs !")
Methods
<Logger>
is any instance of Logger
.
Logging methods
<Logger>.verbose(...<objects or string>)
<Logger>.debug(...<objects or string>)
<Logger>.log(...<objects or string>)
<Logger>.info(...<objects or string>)
<Logger>.success(...<objects or string>)
<Logger>.warn(...<objects or string>)
<Logger>.error(...<objects or string>)
<Logger>.fatal(...<objects or string>)
<Logger>.clear()
Clear node's console (print \x1Bc)
Settings
<Logger>.setLevel(<level | int>)
Set logging level. Can be a level like ... :
Logger.VERBOSE, Logger.DEBUG, Logger.LOG, etc ...
<Logger>.getLevel() : int
Coming soon
- [x] Colorful Logger
- [x] Logging level
- [x] Objects logging
- [x] NPM package
- [ ] Print to file
- [ ] Print to write stream