2.0.0 • Published 4 years ago
@fluidt/logger v2.0.0
🦒 Simple Logger for Node.js
The best alternative to the console.log statement
🎁 Support:
This project is free, open source and I try to provide excellent free support.
📎 Menu
💡 Features
- ✔️ Easy to use
- ✔️ MIT License
- ✔️ Palette (🎨 Customize colors)
- ✔️ The best alternative to the console.log statement
🚀 Installation
- In your node project run:
npm install @fluidt/logger --save - Usage:
const logger = require("@fluidt/logger");
logger.info("message");You can set envs to control logging level export LOG_LEVEL=DEBUG example (logtest.js):
const logger = require("@fluidt/logger");
logger.info("This is an informational");
logger.error("This is an error")Run:LOG_LEVEL=ERROR node logtest.js
See folder tests, run with node run test. Below is available a description of envs values.
🧰 Options
| Parameter | Description | Values | Default value | Available since |
|---|---|---|---|---|
| LOG_LEVEL | Sets Log Level | ERROR, WARN, INFO, DEBUG | DEBUG | v1.0.0 |
| LOG_COLOR_INFO | Set INFO Level color | See Color List below | green | v2.0.0 |
| LOG_COLOR_DEBUG | Set DEBUG Level color | See Color List below | blue | v2.0.0 |
| LOG_COLOR_ERROR | Set ERROR Level color | See Color List below | red | v2.0.0 |
| LOG_COLOR_WARN | Set WARN Level color | See Color List below | yellow | v2.0.0 |
Colors
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- blackBright (alias:
gray,grey) - redBright
- greenBright
- yellowBright
- blueBright
- magentaBright
- cyanBright
- whiteBright
🔌 Methods
| Method | Description | Parameters |
|---|---|---|
debug(message) | message: Display debug log message | message: string (mandatory) |
info(message) | message: Display info log message | message: string (mandatory) |
warn(message) | message: Display warning log message | message: string (mandatory) |
error(message) | message: Display errors log message | message: string (mandatory) |
log(message) | message: Display log message | message: string (mandatory) |
setLogLevel(level) | level: Loglevel for Display | level: string (optional) |
setColors(color) | color: colors for each LogLevel | level: object (optional) |
💫 License
- Code and Contributions have MIT License
Copyright (c) 2021 Dan Abarbanel [contact@fluidt.dev](mailto:contact@fluidt.dev)
Change Log
- v2.0
- Switched to use Javascript class syntax
- Fixed Bug where envs were not being passed as part of the config
- Added support for user defined colors
- Deprecated the
initfunction,setLogLevelshould be used in its place
- v1.0
- Initial Logger Implementation