loading...
Cover image for Beautiful Logger v1.5.0: Custom palette and logrotate!

Beautiful Logger v1.5.0: Custom palette and logrotate!

ptkdev profile image Patryk Rzucidło ・2 min read

Beautiful Logger for Node.js: the best alternative to the console.log statement

The best alternative to the console.log statement for nodejs

Resources: [NPM] [GITHUB]

v1.5.0 Released!

🎨 Palette

Beautiful Logger for Node.js

You can customize palette colors with options.palette with hexcode values.

  • label is text on left (INFORMATION / ERROR / DOCS, etc..)
  • text is message of log on right
  • background is background color on left side

See folder examples, run with node example.js.

🤹‍♂️ Log Rotate

Rotates the file when size exceeds 10 megabytes (optional, default 10M - values: 10B (byte) / 10K (kilobyte)/ 10M (megabyte)/ 10G (gigabyte))

    "rotate": {
        "size": "10M",
        "encoding": "utf8"
    },

👔 Screenshot

Beautiful Logger for Node.js

🚀 Installation

  1. In your node project run: npm install @ptkdev/logger --save
  2. Usage:
const Logger = require("@ptkdev/logger");
const logger = new Logger();
logger.info("message");

You can set options to new Logger(options); example:

const Logger = require("@ptkdev/logger");

const options = {
    "language": "en",
    "colors": true,
    "debug": true,
    "info": true,
    "warning": true,
    "error": true,
    "sponsor": true,
    "write": true,
    "type": "log",
    "rotate": {
        "size": "10M",
        "encoding": "utf8"
    },
    "path": { // remember: add logs folder or files to .gitignore
        "debug_log": "./debug.log",
        "error_log": "./errors.log",
    }
};

const logger = new Logger(options);
logger.info("message");

💫 License

  • Code and Contributions have MIT License
  • Images and logos have CC BY-NC 4.0 License (Freepik Premium License)
  • Documentations and Translations have CC BY 4.0 License

❤️ Thanks! Leave a feedback!

Posted on by:

Discussion

pic
Editor guide
 

I'm a newcomer to this world of tools. At first, I thought this logger would influence the outcome of all the stuff printed by my terminal (when running stuff like npm start.). But now I see I was wrong.
Would you mind explaining what's the use case for such a logger?

Is it a library I can add and implement in my application for better logging information?

 

Is an alternative for console.log()
Is only cute, more readable on terminal, writed log file in json format or text format + log rotate. Nothing more. You can use it as logger of your node app

 

And you can say more "readable" with the different types of logs like errors etc. We developers like this kind of customization 🙏

 

SO CUTE! I love the colors!

 
 

Looks awesome. Cheers